Qt::WindowStaysOnTopHint is not working

  • Hello everyone,

    I need to create a file dialog displayed on top. At first I tried with QFileDialog::getExistingDirectory but I didn't succeed so I changed to:

    QFileDialog dialog(0, Qt::WindowStaysOnTopHint);

    folderPath = dialog.selectedFiles();@

    The first time the dialog is displayed on bottom but the following times is displayed on top.

    Could someone please explain me why this behaviour? It happens in Windows XP/7/8

    Thanks in advance.

  • Qt Champions 2017

    which platform did you try. Normally with above code, it should show on top always. What is the sequence in which this dialog is opened ? If it is X11, you may need to pass Qt::X11BypassWindowManagerHint as well.

  • Hi Dheerendra,

    The application is run in a Windows platform. The sequence is the following:

    • Object A of class 1 is created in main thread and moved to a secondary thread.
    • The previous object creates object B of class 2 and moves it into the main thread.
    • Object B creates the file dialog.

  • I´ve just realised that if I do @setOptions(QFileDialog::DontUseNativeDialog);@

    then the dialog is displayed on top.

    Does anyone know why is this happening?


Log in to reply

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