Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QDialog is going behind QMainWindow after click on QMainWindow screen.......
Qt 6.11 is out! See what's new in the release blog

QDialog is going behind QMainWindow after click on QMainWindow screen.......

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 3 Posters 1.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Milansinh Vadher
    wrote on last edited by
    #1

    Hi All,
    I am developing one QT application, Where I am creating QMainWindow and have one push button on mainwindow.

    After clicking on push button, I am opening QDialog of fixed size.

    Code snippet :
    class TempDialog : public QDialog
    {

    }

    function :
    void MainWindow::on_push_button_clicked() {
    Dialog *dialog = new TempDialog(this);
    dialog->setModal(true);
    dialog->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
    Qt::WindowStayOnTopHint);
    dialog->exec();
    }

    So, When dialog gets created at that time it's on top of Main Window.

    But problem is if we click on main window screen - then dialog is going behind mainwindow screen.

    My requirement is like - I don't wont to move dialog behind mainwindow if we touch on mainwindow screen.

    Note : My Mainwindow is full screen and Dialog is small square box on top of Mainwindow.

    Please suggest me approach how to achieve.

    I am using Linux wayland Display for output.

    Thanks in advance.

    JonBJ 1 Reply Last reply
    0
    • M Milansinh Vadher

      Hi All,
      I am developing one QT application, Where I am creating QMainWindow and have one push button on mainwindow.

      After clicking on push button, I am opening QDialog of fixed size.

      Code snippet :
      class TempDialog : public QDialog
      {

      }

      function :
      void MainWindow::on_push_button_clicked() {
      Dialog *dialog = new TempDialog(this);
      dialog->setModal(true);
      dialog->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint |
      Qt::WindowStayOnTopHint);
      dialog->exec();
      }

      So, When dialog gets created at that time it's on top of Main Window.

      But problem is if we click on main window screen - then dialog is going behind mainwindow screen.

      My requirement is like - I don't wont to move dialog behind mainwindow if we touch on mainwindow screen.

      Note : My Mainwindow is full screen and Dialog is small square box on top of Mainwindow.

      Please suggest me approach how to achieve.

      I am using Linux wayland Display for output.

      Thanks in advance.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @Milansinh-Vadher
      So far as I know it should already stay on top, though I use Xorg not Wayland. Are you sure your TempDialog class does not alter something about the dialog?

      It is possible that there is some "desktop setting" which could alter dialog-topness-behaviour, I don't know.

      You could also test with Dialog *dialog = new TempDialog(nullptr);. This would make the dialog application-modal instead of mainwindow-modal, just to see how that behaves.

      You could also remove your Qt::WindowStayOnTopHint, since that should be necessary, just in case that is actually making it go wrong.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Milansinh Vadher
        wrote on last edited by
        #3

        @JonB Yes i am sure it's not altering anything about dialog.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Which Linux distribution are you using ?
          Are you using a desktop environment and if so which is it ?
          Which version of Qt are you using ?
          Is it the one from your distribution ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Milansinh Vadher
            wrote on last edited by
            #5

            Hi All,

            It's got resolved. Issue was from weston-wayland side and for same weston has given patch.

            After applying that patch issue got resolved.

            https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/210

            Thanks all.

            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