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. [solved] Multiple trayicons appear, per process
Forum Updated to NodeBB v4.3 + New Features

[solved] Multiple trayicons appear, per process

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 2.9k Views 2 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.
  • N Offline
    N Offline
    nitzan
    wrote on last edited by nitzan
    #1

    My app has no window, the only Qt ui is the tray icon.
    The app opens a chromium browser (CEF) and that causes a few new process to run.
    What happens is that for each chromium process another icon appears in the tray, exactly like the initial one (including the icon and menu).

    There's nothing in my code to suggest that something like that should happen, I start the chromium from a different thread and there's nothing to do with Qt in that part of the code.

    Here's how I create the tray icon:

    this->trayIcon = new QSystemTrayIcon(QIcon(TRAYICON_IMAGE), qApp);
    this->trayIcon->setContextMenu(this->trayIconMenu);
    this->trayIcon->setToolTip(TRAYICON_TOOLTIP);
    

    Any ideas as for why that should happen and/or how to solve it so that there will be only that one initial tray icon?

    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      On what platform do you have that happening ? I recall a long time ago I had something like that on Windows but hovering the mouse cursor over the icons made them disappear

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        On what platform do you have that happening ? I recall a long time ago I had something like that on Windows but hovering the mouse cursor over the icons made them disappear

        N Offline
        N Offline
        nitzan
        wrote on last edited by
        #3

        @SGaist

        I'm also on windows (8.1) and hovering doesn't make them disappear, sometimes a process will start and then stop and in that case the icon for that process will indeed disappear when hovered, but while the process is up and running the icon is there to stay.

        Also, I think that even if they would go away when hovered, it's still far from being ideal..

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How are you starting chromium ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nitzan
            wrote on last edited by nitzan
            #5

            I start a new boost thread and in it I run CEF:

            CefInitialize(main_args, settings, app.get(), sandbox_info);
            CefRunMessageLoop();
            CefShutdown();
            

            That creates a few new processes which all have an icon in the tray

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you provide a minimal example that reproduces this ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 1 Reply Last reply
              0
              • SGaistS SGaist

                Can you provide a minimal example that reproduces this ?

                N Offline
                N Offline
                nitzan
                wrote on last edited by
                #7

                @SGaist

                I can write a short Qt program that uses CEF and result in the problem I asked about, but it requires the CEF to downloaded and built on your system which sounds kinda like too much to ask for.

                In the process manager I can see that for each new process that is created for chrome the name is the same as my app (i.e.: MyQtApp.exe), which maybe causes the system to use the same icon as I've set up for the main one?

                Thanks.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  So it looks like the part where you setup the QSystemTrayIcon is called each time you start that process ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    So it looks like the part where you setup the QSystemTrayIcon is called each time you start that process ?

                    N Offline
                    N Offline
                    nitzan
                    wrote on last edited by nitzan
                    #9

                    @SGaist

                    No, I thought so as well at first but I've set a break point to check if that's the case and it is not.
                    I think that what happens is that the system associates that icon with my process name (or something similar) and then just adds an icon per process of the same name.

                    Can something like that happen?


                    Know what, now that I think about it the debugger won't hit that break point since it's another process which it isn't debugging. Even my logs are probably overriding each other...
                    That's probably the problem, I'll start the chromium in another way.

                    Thanks.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Do the copy react on mouse click ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      N 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Do the copy react on mouse click ?

                        N Offline
                        N Offline
                        nitzan
                        wrote on last edited by
                        #11

                        @SGaist

                        I don't understand the question.. what mouse click?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          I mean that if you have a menu or something on your QSystemTrayIcon, do the duplicate also show it ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          N 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            I mean that if you have a menu or something on your QSystemTrayIcon, do the duplicate also show it ?

                            N Offline
                            N Offline
                            nitzan
                            wrote on last edited by
                            #13

                            @SGaist
                            Yes, everything was "cloned".

                            But the problem was indeed that my process would just start over and over again.
                            What happens is that chromium starts up more process, all of them are the same executable as the one who started it to begin with.
                            In your code you need to check whether it is a chromium process (by the command line arguments) and if so call a chromium command to handle this process.

                            I missed that point and so it would just start my (Qt) app over and over again.
                            I did not get what's going on because the logs would just get overridden and no break points got hit because the debugger was attached to the original process...

                            Sorry for wasting time on this, it's just such a weird scenario which I faced for the first time..

                            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