c++qtdialogmodeless

How to disable user interaction in a Qt application when a DialogBox shown?


I have a modeless QDialog box that popup on errors/warning in my Qt application, I want to force the user to only focus on that dialog box and not click anything in the application until they clicked Ok on the dialog box.

I need the dialog box to remain modeless. A solution like hiding the main window or covering it up is not acceptable.

At the moment I'm using setModal(true); to solve my problem. But I think this method might be stopping the main application from executing.


Solution

  • From the documentation:

    If you use show() and setModal(true) together to perform a long operation, you must call QApplication::processEvents() periodically during processing to enable the user to interact with the dialog.