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. Qt::WindowStaysOnTopHint is not working
QtWS25 Last Chance

Qt::WindowStaysOnTopHint is not working

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.2k Views
  • 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 Offline
    C Offline
    Cesius
    wrote on last edited by
    #1

    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
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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
      0
      • C Offline
        C Offline
        Cesius
        wrote on last edited by
        #3

        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
        0
        • C Offline
          C Offline
          Cesius
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved