如何在QT设计器中生成动态进度条? | 您所在的位置:网站首页 › qt导出pdf速度慢添加进度条 › 如何在QT设计器中生成动态进度条? |
while循环阻止了Qt事件循环的正常工作,解决方案是用GUI友好的对象(例如QTimer或更好的QTimeLine)实现相同的逻辑。 另一方面,建议不要修改Qt Designer提供的类,而是实现继承适当的小部件和设计的新类 from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): ... def retranslateUi(self, Dialog): ... import test_rc class Dialog(QtWidgets.QDialog, Ui_Dialog): def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.setupUi(self) def bar(self): timeLine = QtCore.QTimeLine(1000, self) timeLine.setFrameRange(0, 100) timeLine.frameChanged.connect(self.progressBar.setValue) timeLine.start() if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) w = Dialog() w.bar() w.show() sys.exit(app.exec_()) |
CopyRight 2018-2019 实验室设备网 版权所有 |