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 发布