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. QSystemTrayIcon and window focus
Forum Updated to NodeBB v4.3 + New Features

QSystemTrayIcon and window focus

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 523 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.
  • V Offline
    V Offline
    vic.ju
    wrote on last edited by vic.ju
    #1

    Hi folks,

    I just noticed that there is a different behaviour on Windows and macOS if you click the QSystemTrayIcon. My menu is update before it is drawn, so I connected the following slot to QMenu::aboutToShow.

    void updateAction()
    {
        QWidget* activeWidget = QApplication::activeWindow();
        mCloseAction->setEnabled(activeWidget != nullptr);
    }
    

    On macOS the active window is the last focused Window e.g. MainWindow as expected. On Windows (10) on the other hand QApplication::activeWindow() returns a nullptr. Why is the frontmost window not set to be the active window again like on macOS? As far as I understood it, clicking outside of your application lets you lose the focus and therefore you have no active window anymore. I was just wondering if it is recreating native behaviour or if it a bug.

    Best regards,
    Victor

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

      Hi,

      Which version of Qt are you using ?
      Which version of macOS ?
      Which version of Windows ?
      Can you provide a minimal compilable example that shows the behaviour ?

      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
      • V Offline
        V Offline
        vic.ju
        wrote on last edited by
        #3

        Oh sorry, here are the information:

        Qt 5.15.1 (same on Qt 5.14.2)
        MacBook Pro (16-inch, 2019)
        macOS 10.15.6 (19G2021)
        Windows 10 (Build 19041)

        Minimal example: https://ufile.io/gamjo6zy

        1. Start your application and click on any other opened window (or the desktop)
        2. Right click the system tray icon

        The action now is enabled on macOS, but disabled on windows.

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

          Sorry, I have lost track on this thread. Would it be possible to make the example available again ?
          In the mean time, 5.15.2 was released, did you check with it ?

          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

          • Login

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