[Interest] running Qt main event loop in secondary thread

Frank Mertens frank at cyblogic.de
Tue Mar 28 04:23:25 CEST 2023


Hi Stefan,

check out the excellent QThread API docs for the correct patterns for interacting between UI and worker threads.
I don't think that it really matters which thread is your "main" thread. Surely you have to call Q*Application::exec()
in one distinct thread and you definitely can have only one thread of this type running at the same time.

-- 
Frank Mertens


On 3/27/23 22:23, 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...
> 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list