我的问题是,如果选中该复选框,我想继续旋转场景,并在取消选中后立即停止旋转。但是,“继续旋转”意味着无限循环......
所以进入循环后,程序有点冻结,不再对我的“取消选中”信号做出反应。有没有办法中断这个循环?以下是相关代码的骨架。谢谢!
class Draw(QGLWidget):
def __init__(...):
...
self.rotate=0
self.auto=False
def paintGL(self):
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glRotatef(self.rotate,0.0,0.0,1.0)
draw stuff...
glFlush()
def autoRotate(self,auto): # auto is an integer and used here as true/false
self.auto=auto
while self.auto:
self.rotate+=0.5
if self.rotate>360:
self.rotate-=360
self.updateGL()
if auto==False:
break
class SpiralWidgetDemo(QtGui.QMainWindow):
def __init__(self):
...
auto=QtGui.QCheckBox("Auto")
self.connect(auto,QtCore.SIGNAL("stateChanged(int)"),widget.autoRotate)