I am adding a PyQT UI to an existing application. I have to initialize the QAppliaction
via a callback that I receive from that application on the main thread. I can't do that synchronously from the callback because I would eventually have to call app.exec()
which is blocking, preventing the existing application from continuing. Obviously, spawning a regular thread does not work, and I cannot seem to find a way to do it with a QThread
.
This question seems to do exactly what I want in C:
thread = new QThread();
connect(thread, SIGNAL(started()), this, SLOT(onStarted()), Qt::DirectConnection);
thread->start();
where onStarted
eventually calls exec()
. Apparently I am not intelligent enough to achieve the exact same thing in Python. How does it work?