QDialog Question



  • Hi I have a super quick question - in the QDialog documentation it says:

    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. (See QProgressDialog.)
    

    If I'm not performing a long blocking operation I don't need to call processEvents() right? The dialog will return control to the event loop to update the GUI and prevent GUI blocking since there's no blocking operation occurring right? The dialog is just to present information to and get input from the user.
    Thanks


  • Lifetime Qt Champion

    Hi,

    It depends on how you use the dialog (open vs exec). Open will show the dialog and continue execution while exec will block the execution of your application and spin a secondary event loop that will process events in the context of the dialog.



  • So if I use open or show and there's no blocking operation started after I present the dialog there will be no GUI blocking, nothing to worry about right? And open() is the same as setmodal(true) and show() right?



  • Better question - what's the difference between a normal event loop and the one spawned by exec'ing a dialog? Is it just where they originate from? A secondary event loop as mentioned previously will process events in the overall application's event loop right?



  • Did a quick experiment - timers are being run with both modal dialog run from show() and qmessagebox exec()'d. Question answered.


  • Lifetime Qt Champion

    They will indeed, but they won't be handled in the same event loop.



  • Does this have any functional impact on the behavior of the program?


  • Lifetime Qt Champion

    Well, it highly depends on what your program does and what should or shouldn't happen while the dialog is shown.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.