Python Pyside程序锁定以响应复选框单击
我有一个很奇怪的问题。无论何时选中QCheckBox,它都会按预期调用drawall。然而,当drawall完成时,它完全挂起。我曾尝试在单击时直接调用drawall(版本2),但没有成功,结果是一样的Python Pyside程序锁定以响应复选框单击,python,qt4,pyside,Python,Qt4,Pyside,我有一个很奇怪的问题。无论何时选中QCheckBox,它都会按预期调用drawall。然而,当drawall完成时,它完全挂起。我曾尝试在单击时直接调用drawall(版本2),但没有成功,结果是一样的 scene = QGraphicsScene(0, 0, 500, 500) class SurrogateBeat(QGraphicsItem): def __init__(self,beat,top): super(SurrogateBeat, self).__in
scene = QGraphicsScene(0, 0, 500, 500)
class SurrogateBeat(QGraphicsItem):
def __init__(self,beat,top):
super(SurrogateBeat, self).__init__()
print "Init"
class Test(QWidget):
def __init__(self):
self.drawAll = QCheckBox("Draw all frames on screen",self)
self.drawAll.stateChanged.connect(self.onDrawAllClicked)
def onDrawAllClicked(self): #Version 1
QTimer.singleShot(0, self.drawall)
def onDrawAllClicked(self): #Version 2 (neither work)
self.drawall()
def drawall(self):
if self.drawAll.checkState() == Qt.CheckState.Checked:
self.surrogates=[]
for b in range(0,len(self.item.beats)):
print "Loop"
surrogate = SurrogateBeat(b, self.item)
scene.addItem(surrogate)
self.surrogates.append(surrogate)
scene.update()
print "Update"
循环打印16次,代理Beat的init打印出来,因此它被调用,但在“Update”打印出来之后,程序被挂起。是一个抽象基类
作为最低要求,您的
代理Beat
子类将需要重新实现and函数。谢谢,我已经重新实现了绘制函数,但忘记了绑定rect。这完全解决了问题。