--===============1588270543375906937== Content-Type: multipart/alternative; boundary=047d7b60458236eb8b050c17cbd7 --047d7b60458236eb8b050c17cbd7 Content-Type: text/plain; charset=UTF-8 Hi, On Wed, Jan 7, 2015 at 4:11 PM, Ilya Kulakov 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 --047d7b60458236eb8b050c17cbd7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, Jan 7, 2015 at 4:11 PM, Ilya Kulakov <kulakov.ilya@gmail.c= om> 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 clip= board.
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 event= s are delivered.

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

Delivery of signals to an obje= cts slot when the object lives in another thread requires a Qt event loop r= unning in that thread, you won't get around that if you really need a c= ross-thread signal/slot connection.

However an alt= ernative is to keep the slot in the main thread and use standard inter-thre= ad communication (Lock/Condition or Queue from python) to signal whatever y= ou 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 desig= n).

Andreas
--047d7b60458236eb8b050c17cbd7-- --===============1588270543375906937== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KUHlRdCBtYWls aW5nIGxpc3QgICAgUHlRdEByaXZlcmJhbmtjb21wdXRpbmcuY29tCmh0dHA6Ly93d3cucml2ZXJi YW5rY29tcHV0aW5nLmNvbS9tYWlsbWFuL2xpc3RpbmZvL3B5cXQ= --===============1588270543375906937==--