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. QDialog always on top if parented on QMainWindow
Forum Update on Monday, May 27th 2025

QDialog always on top if parented on QMainWindow

Scheduled Pinned Locked Moved General and Desktop
qdialogqmainwindowparent
4 Posts 2 Posters 7.4k 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.
  • J Offline
    J Offline
    Justin Sayne
    wrote on 30 Jul 2015, 13:42 last edited by
    #1

    I've noticed that the QDialogs in my application always stay on top of the main window if they are parented on it. As soon as I don't provide any parent, they can again be stacked independently. Unforunately I now lose the connection between the two widgets, especially that the child widget is always spawned centered inside the parent. Can I somehow combine the two behaviors?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raf924
      wrote on 30 Jul 2015, 14:38 last edited by
      #2

      Hi, I'm not exactly sure what you want to do here, but if you want to remove the "stay on top" behaviour you should change the window flags of your dialog (if it can be done) : http://doc.qt.io/qt-5/qwidget.html#windowFlags-prop, http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html.

      I hope that helps.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Justin Sayne
        wrote on 31 Jul 2015, 14:55 last edited by
        #3

        This won't help as the always on top window flag isn't set by default. It appears as though the described behavior is the intended Qt standard once you set a parent on widgets.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raf924
          wrote on 2 Aug 2015, 05:31 last edited by
          #4

          Yes my bad, I pointed you to the wrong property. Actually you must set the windowModality property : http://doc.qt.io/qt-5/qwidget.html#windowModality-prop, or the modal prop (only for QDialogs) : http://doc.qt.io/qt-5/qdialog.html#modal-prop. I believe that is the solution you've been looking for.

          1 Reply Last reply
          0

          1/4

          30 Jul 2015, 13:42

          • Login

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