锋哥原创的PyQt6视频教程:
QTimeEdit是单纯的时间控件,继承QDateTimeEdit,拥有QDateTimeEdit的所有属性和方法。
UI生成参考代码:
python
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.timeEdit = QtWidgets.QTimeEdit(parent=Form)
self.timeEdit.setGeometry(QtCore.QRect(140, 130, 118, 22))
self.timeEdit.setCalendarPopup(False)
self.timeEdit.setTime(QtCore.QTime(10, 22, 44))
self.timeEdit.setObjectName("timeEdit")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.timeEdit.setDisplayFormat(_translate("Form", "HH:mm:ss"))