Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Thiago Macieira
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

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Stefan Seefeld
Hi Thiago, 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

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Thiago Macieira
On Tuesday, 28 March 2023 06:16:52 PDT Stefan Seefeld wrote: > First I see > the error / warning message > > `WARNING: QApplication was not created in the main() thread.` > > the main window appears, but isn't fully constructed and it doesn't look > like the event loop is ever started. (The

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Stefan Seefeld
Hi again, It looks like the problem is that pyqt5 creates some hidden Qt objects very early (i.e. upon importing some modules). If I move the imports as well as the `MainWindow` definition into the secondary thread, everything appears to be working fine. On Tue, Mar 28, 2023 at 9:16 AM Stefan

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Stefan Seefeld
On Tue, Mar 28, 2023 at 3:04 AM Samuel Gaist wrote: > > Did you consider the use of pytest-qt[0] ? > I did indeed, but it seems its functionality isn't entirely suitable for my needs: I really do need to run the event loop continuously in the background (rather than occasionally running

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Stefan Seefeld
Thanks all for the quick follow-up ! It's good to hear that what I have in mind *should* work. However, I'm actually struggling a bit with the implementation. I have attached a very simple test-case creating a simple (pyqt5) app. If I call the `main()` function rather than `run_app()` directly,

Re: [Interest] running Qt main event loop in secondary thread

2023-03-28 Thread Samuel Gaist via Interest
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

Re: [Interest] running Qt main event loop in secondary thread

2023-03-27 Thread Thiago Macieira
On Monday, 27 March 2023 13:23:02 PDT 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

Re: [Interest] running Qt main event loop in secondary thread

2023-03-27 Thread Frank Mertens
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

[Interest] running Qt main event loop in secondary thread

2023-03-27 Thread Stefan Seefeld
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