[Interest] running Qt main event loop in secondary thread

Samuel Gaist samuel.gaist at idiap.ch
Tue Mar 28 09:03:19 CEST 2023

On lundi, 27 mars 2023 22.23:02 h CEST Stefan Seefeld wrote:
> Hello,
> I'm working on some Python tests that interact with a Qt application. I
> would like to run the application's event loop in a secondary thread, so
> the primary thread can perform the test itself.
> I read in the past that such a use-case wasn't supported by Qt, but I can't
> find that information right now, and neither do I remember the rationale
> for that limitation.
> Could anybody please either confirm or deny this limitation, ideally with
> some background information ?
> For context: my application is somewhat atypical in that the application
> only has a minimal GUI, but does a lot of processing of input from TCP/IP.
> The test logic I'd like to write would thus have test function (running in
> the primary thread) control the data sent to the app and inspect and assert
> the application's corresponding states, while the event processing would
> take place in a secondary thread.
> I'm unfortunately not sure that such a use-case is possible at all, i.e. I
> may have to invert roles, i.e. have the actual "test scenario" be executed
> in a secondary thread as the main thread is reserved for the (blocking)
> event loop.
> Thanks for any information & suggestions !
>       ...ich hab' noch einen Koffer in Berlin...


Did you consider the use of pytest-qt[0] ? 

It allows to test the various aspects of your widgets and other Qt based 
business logic without having to manage yourself the creation of a 
QApplication object or the need to add threads.

Best regards


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230328/39927c56/attachment.sig>

More information about the Interest mailing list