【发布时间】:2016-11-13 11:17:49
【问题描述】:
我是使用 PyQt4 QTimer 的新手。我只是从某个地方复制代码,但似乎它不起作用。有人可以帮我解决这个问题吗?
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import *
from PyQt4.QtCore import *
def startCount():
timer.start(1000)
def showNum():
global count
count = count + 1
return count
timer = QtCore.QTimer()
count = 0
timer.timeout.connect(showNum)
startCount()
我希望看到计数随时间增加,但控制台没有显示任何输出。有人可以解释一下吗?
【问题讨论】:
-
忘记更正showNum函数的返回,但不是屏幕不显示的问题。使用 print 时,结果相同。