Reputation: 90776
I have a Qt application with a system tray icon and a menu that shows up when right-clicking the icon. For some reason, the menu items work fine in debug mode but not in release mode.
QAction* closeAction = new QAction("Close", this);
QMenu* trayIconMenu = new QMenu(this);
trayIconMenu->addAction(closeAction);
QSystemTrayIcon* trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
QIcon trayIconIcon("Application.png");
trayIcon->setIcon(trayIconIcon);
trayIcon->show();
QObject::connect(closeAction, SIGNAL(triggered()), this, SLOT(trayIconCloseAction_triggered()));
void MainWindow::trayIconCloseAction_triggered() {
MessageBoxes::info("Close item clicked");
}
When I right-click on the icon, the menu shows up but clicking on "Close" does nothing - trayIconCloseAction_triggered()
is not called at all. It does this only in release mode. Does anybody know what could be the reason?
I am using Windows 7 and Qt Creator, building with an MSV-2010 static build of Qt.
Edit: The icon does not react to click events ("activated" signals) either. Again in debug mode it works, but not release.
Upvotes: 0
Views: 2436
Reputation: 1974
In situations like this there is a general recommendation:
Upvotes: 1