Modal dialog can loose focus, bug or intended ?
-
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
-
Hi and welcome to devnet,
Could you show the code where you use the dialogs ? Also, what OS/Qt version are you using ?
-
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
-
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
-
How does it behave if you don't give it a parent ?