这是我的代码,当我运行它时,它不像时钟。它只返回一个字符串。但我想要的是以秒为单位的时间。谢谢你的帮助
def DateTime(self):
dateandtime = QDialog()
dateandtime.setWindowTitle("Date and Time")
hbox = QHBoxLayout()
datetime = QDateTime.currentDateTime()
show = datetime.toString(Qt.DefaultLocaleLongDate)
label = QLabel(show)
label.setFont(QtGui.QFont("Arial", 10))
hbox.addWidget(label)
dateandtime.setLayout(hbox)
应该有一种更优雅的方式,但是可以找到一个计时器的例子:
相关问题 更多 >
编程相关推荐