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. ActiveWindow() don't run on mac

ActiveWindow() don't run on mac

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.2k 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.
  • U Offline
    U Offline
    unnormal
    wrote on last edited by
    #1

    Hi!
    I'm new here and I have a problem when building app on mac
    I want to use activeWindow() on top window but it don't run, i also try use show(), raise() but nothing happen.

    Thanks.

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

      Hi and welcome to devnet,

      Without any code and no Qt version nobody's gonna be able to help you. Please show us the code that is not working for you.

      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
      • U Offline
        U Offline
        unnormal
        wrote on last edited by
        #3

        Sorry, this is my mistake
        I use qt5.0.2 on mac. I have a QSystemTrayIcon, in the case my application is obscured by other window and i want to active it when click TrayIcon. My code is simple:
        @
        void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
        {
        activeWindow();
        }
        @

        I also try to use:
        @
        void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
        {
        show();
        raise();
        activeWindow();
        }
        @

        but nothing happen, it still under the other window. can you help me ?
        thanks

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

          It might be just a typo on your side but shouldn't you be using activateWindow ? activeWindow will return the top-level window that has the keyboard focus.

          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
          • U Offline
            U Offline
            unnormal
            wrote on last edited by
            #5

            But why it runs fine on the window environment, on mac it don't run ? If i don't use activeWindow() function, is there other way ? I just want to active window on top when click TrayIcon.
            Thanks.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Skh1002
              wrote on last edited by
              #6

              As SGaist indicated, it appears that you should be using the QWidget::activateWindow() call on your main window object (it's 'activate', not 'active').

              Unless there are some side effects or bugs in Qt under Windows, your code using activeWindow() should not bring your main window to the top.

              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