How to disable a window when a new dialog in on top of it?
Sriu1 last edited by
I have mainwindow.ui with some buttons.Finish,Exit,New Dialog etc...
When "New Dialog" is clicked I'm creating a dialog box with "OK" and "Cancel" buttons.This dialog box appears on top of my mainwindow.I have a requirement that, only after user clicks "Ok" or "Cancel" in the dialog the buttons in the mainwindow should be functional otherwise the buttons in the background should not be functional.Please suggest.
This is called window modality. You can set it using modality property.
And here is a bit more info on how it works: https://doc.qt.io/qt-5/qt.html#WindowModality-enum
JonB last edited by
You don't even have to bother to set the modality. Assuming you will use
QDialog::exec()as your way of displaying the dialog, it does all that you want already:
exec()ignores the value of this [
modal] property and always pops up the dialog as modal.