My Qt application's main window is a normal QMainWindow
subclass. In that window I have a few buttons; each has its clicked
signal connected its own slot, and each slot creates a different QDialog
like so:
void onButtonA_clicked()
{
MyADialog* dialog = new MyADialog(this);
dialog->exec();
delete dialog;
}
I've been reading this article: https://wiki.qt.io/Threads_Events_QObjects#Events_and_the_event_loop and the author says
you should never ever block the event loop
which got me concerned; exec
is a blocking function, so according to what he says there (his example with Worker::doWork
which does a lot of work and needs some time to complete) my code is blocking the event loop, but I have not noticed anything that would suggest this; on the contrary, the main window seems to behave normally, and there was no difference when I changed the code to use the show()
method.
Am I blocking the event loop? Should I use a different approach here?
int QDialog::exec()
doesn't block the Qt application, just the parent window and only if the dialog is window modal. – Inning