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. Modal dialog can loose focus, bug or intended ?
Qt 6.11 is out! See what's new in the release blog

Modal dialog can loose focus, bug or intended ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.5k 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.
  • P Offline
    P Offline
    Pluc
    wrote on last edited by
    #1

    Hello,

    If I 'exec' a modal dialog, or using the QInputDialog helpers, and then I click on the main application window, the dialog will loose focus.

    So the dialog is now hidden behind the main window (the main window being still 'blocked' by the dialog). This is especially unconvenient for a full screen application, the only way to have a the dialog again is to use ALT + TAB or whatever the window manager is configured, not so user friendly.

    I can't compile anymore with Qt4, but I think to remember this was not the behavior before, i.e clicking on the main window would do nothing if a modal dialog is executing (or maybe even better, the dialog would visually shake).

    So, is this intended, or a bug in Qt5 ? Didn't find anything in the bug tracker or in Google.

    I tried different flag combination (AlwaysOnTop, etc) without success. My hack for the moment is to set Qt::PopUp so the dialog will close when clicked outside, but this is not I want :)

    Thanks

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

      Hi and welcome to devnet,

      Could you show the code where you use the dialogs ? Also, what OS/Qt version are you using ?

      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
      • P Offline
        P Offline
        Pluc
        wrote on last edited by
        #3

        Hello,

        I'm using Qt 5.0.1 on Ubuntu 13.04 64bit.
        I used the packaged version : 5.0.1+dfsg-0ubuntu4
        Linux **** 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
        My window manager is Cinnamon 1.7.4-1.

        An example code snippet :

        @
        bool ok;
        QString pw;

        pw = QInputDialog::getText(this, QString{}, tr("Gimme your password"), QLineEdit::Password, QString{}, &ok,
        // Qt::FramelessWindowHint | Qt::Popup
        );
        @

        I also tried with a "normal" QDialog :

        @
        QDialog foo(this);
        foo.setModal(true);
        foo.exec()
        @

        Cheers

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pluc
          wrote on last edited by
          #4

          Ok, guess I just found out...

          My application is typically like this :

          QFrame -> Layout -> main QWidget -> QDialog

          So instead of just this for the parent of the dialog, I tried this->parentWidget(), which points to the first QFrame.

          This works as intended :)

          But a modal dialog should always have this behavior, whatever his parent, no ?

          Cheers

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

            How does it behave if you don't give it a parent ?

            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

            • Login

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