I am newbie to OOP and python. I am trying to emit signal from Qthread to Qt GUI main window using new style signals and slots.
This is the thread. Inside I will emi
The structure of your example is more or less right: but you are mixing up the old-style signal-slot syntax with the new-style.
The signal definition should look like this:
class OptimThread(QtCore.QThread):
signalUpdateMessageDialog = QtCore.pyqtSignal(int, str)
The signal should be emitted like this:
self.signalUpdateMessageDialog.emit(
time.time() - start, 'Initialising...')
And this is how the signal should be connected:
self.optimThread.signalUpdateMessageDialog.connect(
self.updateMessageDialog)
With the new-style syntax, there is never any need to use SIGNAL()
or SLOT()
, and it is never necessary to specify the C++ signature.
For further details, see New-style Signal and Slot Support in the PyQt4 reference.