我试图将泛型数据类的子类化,以便对父级计算的数据执行一些附加操作。我想在子类中重用dataReady
信号。问题是信号仍然从父节点发出,并在附加计算完成之前触发连接的插槽。在
是否可以重写/抑制父类发出的信号,或者只需选择一个不同的信号名?在
下面是我的课程的一个简化示例:
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()
我会重新组织一下课程。在
现在,您的
initData
方法不需要更改,它本应进行一些计算,然后发送信号,MoreSpecific
类只发送一次信号。在您可以使用blockSignals:
相关问题 更多 >
编程相关推荐