I am trying to create a program, using PyQt, which currently consists of a stacked widget of 4 pages. A timer has been implemented, and after 3 seconds the page the user is currently on switches to the next page. I am currently trying to add a timer which shows the user how much time on that page they have left (ideally in seconds). However, I have no idea how to connect the timer to a counter, and have not been able to find anything which would be helpful.
Here is the current code, which is basically just the timer:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from StackedWidget import *
app = QApplication(sys.argv)
window = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(window)
def NextTimer():
ui.stackedWidget.setCurrentIndex((ui.stackedWidget.currentIndex() + 1))
myTimer = QTimer()
myTimer.timeout.connect(NextTimer)
myTimer.start(3000)
I am trying to connect the timer to a counter of the class QLCDNumber,labelled Counter. At the current point there is no code which involves this counter, it just exists.
Thank you for any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…