Hi,

On Wed, Jan 7, 2015 at 4:11 PM, Ilya Kulakov <kulakov.ilya@gmail.com> wrote:
I have a python thread that mainly serves a network connection. In this thread (due to the logic/architecture of my app) I need connect to a slot of QApplication clipboard.
Something straightforward like connect does not work because my thread does not have a Qt event loop. However if I connect with a DirectConnect, I'll get my callback called, but sometimes it simply stops to work: no events are delivered.

Is there any utility classes in PyQt to subscribe to Qt events from non-Qt threads?

Delivery of signals to an objects slot when the object lives in another thread requires a Qt event loop running in that thread, you won't get around that if you really need a cross-thread signal/slot connection.

However an alternative is to keep the slot in the main thread and use standard inter-thread communication (Lock/Condition or Queue from python) to signal whatever you need to communicate to the thread.

Qt and PyQt offer some threading API as well (QThread, QMutex, QSemaphore, QFuture) but I think you'd have to use QThread for those to work correctly for your thread (and it sounds like that is also a significant change in your design).

Andreas