[PyQt] How to get Qt signals delivered to a pure python thread.
giuseppe.corbelli at copanitalia.com
Thu Jan 8 09:13:50 GMT 2015
On 08/01/2015 09:00, Ilya Kulakov wrote:
> Thank you for all your response!
> So you're saying that DirectConnect is perfectly safe when connecting from
> a thread without qeventloop?
If you connect a slot of ThreadB to the (ie) QClipboard.changed signal with
DirectConnection, the slot will be called (as direct function call) in the
thread where QClipboard lives in, likely the main thread. Synchronization must
be handled manually.
> More Qt question rather than pyqt, but is it possible to control run time
> of an event loop? According to docs, there is just a blocking exec function and
> it's not possible to run qeventloop for N seconds (as e.g. Cocoa's CFRunLoop).
Yes, but you can repeatedly call processEvents() in a while loop and
constantly check the elapsed time.
> Another approach that I tried is to have a proxy qobject that is moved to
> the main thread just after creation and then uses simple python callbacks to
> invoke methods of my other-thread object. Is it better than DirectConnect?
Again, synchronization must be handled. You may also consider a mailbox
(synchronized queue). Push data from the main thread and pop from the secondary.
WASP Software Engineer, Copan Italia S.p.A
Phone: +390303666318 Fax: +390302659932
E-mail: giuseppe.corbelli at copanitalia.com
More information about the PyQt