[Interest] running Qt main event loop in secondary thread

Thiago Macieira thiago.macieira at intel.com
Wed Mar 29 03:50:02 CEST 2023

On Tuesday, 28 March 2023 13:23:58 PDT Stefan Seefeld wrote:
> if you have a look at the little sample script I attached to my mail you'll
> see that I'm actually constructing the application object within the
> function that is executed in the other thread.
> I do however import PyQt5 modules at the top of my script, and if I move
> those imports into the function the warning goes away.
> Does this suggest that PyQt5 itself instantiates a QApplication as a global
> object ?


It suggests that PyQt5's loading process creates at least one QObject, but not 
a QCoreApplication/QApplication object. And as I said about the libraries 
themselves, I can't guarantee that one of them won't create such object just 
by linking to it. I can only guarantee QtCore doesn't (in 6.5; I can't 
guarantee earlier versions).

You must cause there to be NO QObject creations at all, if you want to create 
your QCoreApplication in another thread. If you can't ensure that, then you 
must accept defeat and create the QCoreApplication in that thread where the 
first QObject was created.

Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230328/1375181a/attachment.bin>

More information about the Interest mailing list