def initUI(self):
self.setWindowTitle('QSpinBoxDemo')
self.setGeometry(500,500,300,200)
label1 = QLabel('current value')
label1.setAlignment(Qt.AlignCenter)
spinBox1 = QSpinBox()
spinBox1.setValue(18)#设置默认值
spinBox1.setRange(10, 99) #设置范围
spinBox1.setSingleStep(2) #设置步长
spinBox1.valueChanged.connect(lambda :self.valueChanged(label1))
layout = QVBoxLayout()
layout.addWidget(label1)
layout.addWidget(spinBox1)
self.setLayout(layout)
def valueChanged(self,label):
label.setText('current value:'+str(self.sender().value())) #
13.QSpinBox 计数器控件
最新推荐文章于 2022-11-21 15:10:27 发布
本文详细介绍如何使用PyQt中的QSpinBox控件,包括设置窗口标题、尺寸、控件默认值、范围、步长,以及如何连接信号和槽实现值改变时的动态更新。

743

被折叠的 条评论
为什么被折叠?



