Vasundhara Mehta
Vasundhara Mehta

Reputation: 278

prevent QApplication::exec from blocking main thread

I have a visual c++ program which creates multiple GUI on the main thread. I want to show a QWidget alongside all the other GUI. Currently, if I call QApplication.exec(), it blocks the main thread until I close the window. Is there any way to prevent the exec function from blocking the main thread or to use QWidget without calling exec?

Upvotes: 1

Views: 576

Answers (1)

The method is not blocking the main thread, on the contrary: it allows the event loop to execute, ensuring that the UI remains responsive.

While the widget is shown, all the other GUI will be responsive, as Qt's event loop fully interoperates with the native message queue.

If you want something to happen when a dialog widget gets closed, connect the relevant code to e.g. the dialog's accepted() signal.

Upvotes: 0

Related Questions