Qthread Updating Ui Statusbar?
I have a simple pyqt gui which creates a qthread to open a file and read some information. I want to update the statusbar of my gui. Normally, this would be my function call to u
Solution 1:
You must never attempt to update the GUI from outside the GUI thread. Instead, add a custom signal to the worker thread and connect it to a slot in the GUI:
class WorkThread(QtCore.QThread):
statusMessage = QtCore.pyqtSignal(object)
...
def run(self):
self.statusMessage.emit(self.text)
class gui1(QtGui.QMainWindow):
def __init__(self, parent=None):
super(gui1, self).__init__(parent)
self.mythread = WorkThread(text)
...
self.mythread.statusMessage.connect(self.handleStatusMessage)
@QtCore.pyqtSlot(object)
def handleStatusMessage(self, message):
self.ui.statusBar().showMessage(message)
Post a Comment for "Qthread Updating Ui Statusbar?"