What is the correct way to initialize a QApplication without blocking in QApplication::exec()?
-
I need to open a window of a Qt application inside another application, I created a shared object that creates this window, however when I call the function that creates the window it blocks the QApplication.exec() function and this interferes with the entire remaining application.
How do I get to display the window without blocking in QApplication::exec()?
-
The easiest method is to run the Qt portion in its own thread, allowing QCoreApplication::exec() to block without interfering with the non-Qt portion of the program.
At the other end of the spectrum QAbstractEventDispatcher enables integrating with another event loop in the same thread.
Calling QCoreApplication::processEvents() can work, but as the documentation puts it:
Use of this function is discouraged. Instead, prefer to move long operations out of the GUI thread into an auxiliary one and to completely avoid nested event loop processing. If event processing is really necessary, consider using QEventLoop instead.