Issue
I'm trying to subclass a generic data class to perform some additional operations on the data computed by the parent. I would like to reuse the dataReady
signal in the subclass. The problem is that the signal is still emitted from the parent, and triggers the connected slot(s) before the additional computations have completed.
Is it possible to override/suppress signals emitted from the parent class, or will I simply have to choose a different signal name?
Here's a simplified example of my classes:
class Generic(QtCore.QObject):
dataReady = pyqtSignal()
def __init__(self, parent=None):
super(Generic, self).__init__(parent)
def initData(self):
# Perform computations
...
self.dataReady.emit()
class MoreSpecific(Generic):
dataReady = pyqtSignal()
def __init__(self, parent=None):
super(MoreSpecific, self).__init__(parent)
def initData(self):
super(MoreSpecific, self).initData()
# Further computations
...
self.dataReady.emit()
Solution
You can use blockSignals:
def initData(self):
self.blockSignals(True)
super(MoreSpecific, self).initData()
self.blockSignals(False)
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.