Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt::WindowStaysOnTopHint is not working

    General and Desktop
    2
    4
    1919
    Loading More Posts
    • 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.
    • C
      Cesius last edited by

      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);
      dialog.setOptions(QFileDialog::ShowDirsOnly);
      dialog.setFileMode(QFileDialog::Directory);
      dialog.setDirectory(QDir::homePath());

      if(dialog.exec())
      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.

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        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.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 0
        • C
          Cesius last edited by

          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.
          1 Reply Last reply Reply Quote 0
          • C
            Cesius last edited by

            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?

            Thanks.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post