Answer the question
In order to leave comments, you need to log in
Passing information to the main PyQt4 thread: how?
Dear colleagues. There was a problem: I wrote a module, made a GUI, wrote a Scrapy spider, but I can’t pass information to the main GUI thread.
When developing, I used the SimpleThread module ( habrahabr.ru/post/125699 ) and programmed the button into another thread (so that Gui does not freeze during operation). But I can't pass information to QLabel.
Of course, I used SLOT-SIGNAL:
from PyQt4 import QtCore
@QtCore.pyqtSlot(object)
def saySomething(stuff):
print stuff
class Communicate(QtCore.QObject):
speak = QtCore.pyqtSignal(object)
someone = Communicate()
someone.speak.connect(saySomething)
someone.speak.emit("Test text!")
Answer the question
In order to leave comments, you need to log in
You saved the code that works, but you didn't save the code that doesn't actually work.
Try to make a basic case without simple_thread first: An object of a class inherited from QThread, the signal is sent from the run () method. QLabel.setText receives the signal. This all happens in a running application (after app.exec_())
In principle, signal-slots between threads in Qt work fine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question