ActiveWindow() don't run on mac



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


  • Lifetime Qt Champion

    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.



  • 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


  • Lifetime Qt Champion

    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.



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.