Please nominate your Qt Champions for 2021!

Steal the focus from a full screen app in Mac OS X

  • Hi!

    I want to open a file dialog on top and it works setting the Qt::WindowStaysOnTopHint flag. The problem is that if there is other application running on full screen my dialog doesn't get the focus.

    How could I do it?


  • Lifetime Qt Champion


    What version of Qt are you using ? Running on which version of OS X ?

    Can you show a minimal code sample the shows the behavior ?

  • Hi SGaist,

    I´m using Qt 5.3 running on OS X 10.9. I can´t show you the code because I´m not at work but I found that calling raise() after show() sets my dialog as the active window.

    The problem is that after closing the dialog, the previous active app doesn´t recover the focus unlike on Windows.

    Could a good approach be getting the PID of the active app before showing the dialog and setting that app as the active one after closing it? I could do it with applescripts. Do you think there´s an easier way?


  • Lifetime Qt Champion

    Which version of 5.3 ?

    Do you mean your own application doesn't get the focus back ?

  • My app needs to collaborate with browsers in order to upload files selected by the user. The workflow is:

    The browser is on top and the user clicks on our website

    The Qt app displays a file dialog on top

    The user select the files he wants to upload

    The browser recovers the focus and the app upload the files on the background

    If the browser is not on full screen mode, it works fine. The problem is that with full screen mode I need to raise the dialog to be displayed on top and after the user select the files it doesn´t get back to the browser.

    On Windows this issue doesn´t exist. Despite being on full screen the dialog is displayed on top but on OS X the behaviour is different.

    I´d need to check it tomorrow but I think the version is 5.3.1

Log in to reply