We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signals are not getting through if sender and receiver are in different threads.
import time from PySide.QtCore import * from PySide.QtGui import * class NoiseMaker(QObject): noise = Signal(int) def work(self): while True: print "Making some noise" self.noise.emit( 100 ) time.sleep(0.5) class Listener(QObject): def work(self): while True: time.sleep(0.5) def receiveNoise(self, integer): print "Got some noise" class App(QApplication): def __init__(self): super( App, self ).__init__([]) # Create workers self.noiseMaker = NoiseMaker() self.listener = Listener() # Create threads self.noiseMakerThread = QThread() self.listenerThread = QThread() # Move workers to threads self.noiseMaker.moveToThread( self.noiseMakerThread ) self.listener.moveToThread( self.listenerThread ) # NoiseMaker emits to Listener self.noiseMaker.noise.connect( self.listener.receiveNoise ) # Start noise thread self.noiseMakerThread.started.connect( self.noiseMaker.work ) self.noiseMakerThread.start() # Start listener thread self.listenerThread.started.connect( self.listener.work ) self.listenerThread.start() App().exec_()
Expected output: Making some noise Got some noise
Actual output: Making some noise
However: If you comment out these lines the example works:
self.noiseMaker.moveToThread( self.noiseMakerThread ) self.listener.moveToThread( self.listenerThread )
Alternatively, if you move both workers to the same thread, that also works:
self.noiseMaker.moveToThread( self.noiseMakerThread ) self.listener.moveToThread( self.noiseMakerThread )
The text was updated successfully, but these errors were encountered:
has this ever been resolved? I have a similar problem. As soon as I move my QObject into another thread the signals are not working
Sorry, something went wrong.
No branches or pull requests
Signals are not getting through if sender and receiver are in different threads.
Expected output:
Making some noise
Got some noise
Actual output:
Making some noise
However:
If you comment out these lines the example works:
Alternatively, if you move both workers to the same thread, that also works:
The text was updated successfully, but these errors were encountered: