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. Test doubleclick on QSystemTrayIcon
QtWS25 Last Chance

Test doubleclick on QSystemTrayIcon

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 3.3k Views
  • 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.
  • K Offline
    K Offline
    kjoo
    wrote on last edited by
    #1

    I'm trying to test that my application gets activated when the system tray icon is double-clicked.
    Since QSystemTrayIcon is not derived from QWidget, I can't use QTest::mouseDClick.

    The only solution i have found sofar is using the windows funtions SetCursorPos and mouse_event, but it seems very brittle to have to move the cursor to a certain position and have it double-click there.

    Is there a QT way of doing this instead?

    BR. Kenneth.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ARASHz4
      wrote on last edited by
      #2
      Tray->connect(Tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
                          SLOT(RestoreWindowTrigger(QSystemTrayIcon::ActivationReason)));
      
      void MainWindow::RestoreWindowTrigger(QSystemTrayIcon::ActivationReason RW)
      {
          if(RW == QSystemTrayIcon::DoubleClick)
          {
              show();
              activateWindow();
          }
      }
      
      K 1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @kjoo said in Test doubleclick on QSystemTrayIcon:

        I'm trying to test that my application gets activated when the system tray icon is double-clicked.

        you can manually emit the signal: tray->activated(QSystemTrayIcon::DoubleClick);

        I know it's not exactly the same as actually double clicking but if you are not reimplementing QSystemTrayIcon then you do not need to test the link between click and signal as it is already done in Qt's own tests

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        K 1 Reply Last reply
        2
        • VRoninV VRonin

          @kjoo said in Test doubleclick on QSystemTrayIcon:

          I'm trying to test that my application gets activated when the system tray icon is double-clicked.

          you can manually emit the signal: tray->activated(QSystemTrayIcon::DoubleClick);

          I know it's not exactly the same as actually double clicking but if you are not reimplementing QSystemTrayIcon then you do not need to test the link between click and signal as it is already done in Qt's own tests

          K Offline
          K Offline
          kjoo
          wrote on last edited by
          #4

          @VRonin Thanks. I think this is a good solution.

          1 Reply Last reply
          0
          • A ARASHz4
            Tray->connect(Tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
                                SLOT(RestoreWindowTrigger(QSystemTrayIcon::ActivationReason)));
            
            void MainWindow::RestoreWindowTrigger(QSystemTrayIcon::ActivationReason RW)
            {
                if(RW == QSystemTrayIcon::DoubleClick)
                {
                    show();
                    activateWindow();
                }
            }
            
            K Offline
            K Offline
            kjoo
            wrote on last edited by
            #5

            @ARASHz4 Thanks. I already had that written. I was trying to make a unit-test that tested it.

            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