Is there a way of opening a QDialog window-modal with exec()? open() returns immediately, and exec() shows the dialog application-modal instead of window-modal. How to take the best of both methods?
1 Answer
In Qt there exist window-modality.
For example, showing a dialog this way, from inside a QWidget-derived class, will make the dialog window-modal to its parent:
QDialog d(this);
//...
d.setWindowModality(Qt::WindowModal);
d.exec();
being this
a QWidget
, set as the QDialog
parent.
-
I have tried this, but my child dialog had been refusing to show unless I provided NULL as its parent. I fixed it with removing setWindowFlags(Qt::WindowCloseButtonHint) from the dialog's constructor. Feb 1, 2018 at 0:01