Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to prevent multiple tray icons
Forum Updated to NodeBB v4.3 + New Features

How to prevent multiple tray icons

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adnan
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        Which Qt version are you using? Btw are you experiencing this issue on all OS (Windows, Mac OS, Linux)?

        http://anavi.org/

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on last edited by
          #4

          Songs like coding failure... show us your code where QSystemTray is created and how dialogs are called.

          God is Real unless explicitly declared as Integer.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adnan
            wrote on last edited by
            #5

            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();"@

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AcerExtensa
              wrote on last edited by
              #6

              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...

              God is Real unless explicitly declared as Integer.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved