【发布时间】:2018-05-01 05:13:51
【问题描述】:
我正在尝试在 QThread 中使用单次计时器,但它不起作用。以下是我正在使用的代码:
class thread1((QtCore.QThread):
def __init__(self,parent):
QtCore.QThread.__init__(self, parent)
self.Timer1 = None
def __del__(self):
self.wait()
def timerPINNo(self):
print "Timer completed"
def run(self):
tempVal0 = getData()
if tempVal0 == 0:
self.Timer1 = QtCore.QTimer()
self.Timer1.timeout.connect(self.timerPINNo)
self.Timer1.setSingleShot(True)
self.Timer1.start(5000)
else: pass
我面临的问题是,超时后 timerPINNo 函数永远不会被调用。单发在正常使用时有效,但在我从 QThread 调用时无效。我在哪里犯错了?
【问题讨论】:
标签: python python-2.7 pyqt pyqt4 qthread