How to prevent multiple tray icons
-
My application has a QSystemTray icon. But when i invoke any dialog of the application, two tray icons appear, if the main window is minimized, if main window is not minimized it works fine. But, how to prevent multiple tray icons in case main window is minimized
-
It's really hard to try to help you with such a general description. Try to throw in some implementation details or, better yet, some code that you use to set up the tray icon.
-
Which Qt version are you using? Btw are you experiencing this issue on all OS (Windows, Mac OS, Linux)?
-
Songs like coding failure... show us your code where QSystemTray is created and how dialogs are called.
-
I am using Linux, Gnome Shell. Here are the details:
The code in constructor of main window
@ trayIcon = new QSystemTrayIcon(this);
trayIcon->setIcon(getTrayIcon());
trayIcon->show();
trayIcon->setContextMenu(trayIconMenu);@Now, i call all the dialogs and widgets using:
@testDialog.show();@Now, if the main window in minimized, you may be wondering how i invoke the dialog window, actually i use QtSingleApplication class, whenever main window is invoked, provided one instance of program is already running and minimized, i invoke the dialog using the following code:
@int main(int argc, char *argv[])
{
QtSingleApplication a(argc, argv);if(a.isRunning()&&argc==2) { a.sendMessage(argv[1]); return 0; } else if (a.isRunning()) { return 0; } testApp w; testApp.show(); a.setQuitOnLastWindowClosed(false); if(argc==2) { w.showDialog(argv[1]); } QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &w, SLOT(showDialog(QString))); return a.exec();
}@
Now, the slot showDialog simply calls
@testDialog.show();"@ -
bq. I am using Linux, Gnome Shell. Here are the details:
If you are using Ubuntu it can be Unity/Ubuntu Shell problem, try to test it in another OS to be sure...