This may be a little long post, so, thanks in advance to be with me till the end. Here is the problem, (i think a fairly basic one, just my inexperience with PiSide and Qt m
The problem lies in how you connect the signal to the slot:
QtCore.QObject.connect(self.processThread, QtCore.SIGNAL("progress(int)"),self.progressBar, QtCore.SLOT("setValue(int)"), QtCore.Qt.DirectConnection)
Here, you explicitely enforce a DirectConnection. This is wrong! It makes the slot be processed in the caller's thread. This means that the GUI update of the progressBar happens in the process thread, not in the GUI thread. However, drawing is only allowed in the GUI thread.
It is perfectly fine to connect a signal from one thread to a slot from another. However, you need either AutoConnection
(the default, which will recognize the threads and use QueuedConnection
) or QueuedConnection
.
This line should fix your problem:
QtCore.QObject.connect(self.processThread, QtCore.SIGNAL("progress(int)"),self.progressBar, QtCore.SLOT("setValue(int)"), QtCore.Qt.QueuedConnection)
See http://doc.qt.io/archives/qt-4.7/qt.html#ConnectionType-enum.