Re: moveToThread and signals
Giuseppe Corbelli <[email protected]>
| Newsgroups | gmane.comp.python.pyqt-pykde |
|---|---|
| Message-ID | <[email protected]> |
On 7/3/19 11:58 PM, David Morris wrote: > I have just observed some odd behavior and would like to know if this is > normal or a bug. > > I have a non-Qt thread where I create a Qt object, connect a signal, > move the object to the main application thread, then use the signal to > execute a callback function within the Qt event loop. Here is some > sample code that can be copied directly into a python instance: ... > Is this acting as expected? If so, can anyone explain why the first > version does not work but the other two both work? Or is there a bug > involved in the first configuration? Disclaimer: I'm basically a (Py)QT user, so I don't know enough of the internals. AFAIU when you connect() a signal to a slot the corresponding link is placed in thread local storage of the object thread at connection time. That would explain why your last example works as expected while the first is not. Could be that the pyqtSlot decorator has a side effect to just delay such connection so that we head back in the above case. BTW, you're not supposed to move the application to another thread. Could be OK for some simple testing but even there what if it yields unexpected results? -- Giuseppe Corbelli _______________________________________________ PyQt mailing list [email protected] https://www.riverbankcomputing.com/mailman/listinfo/pyqt