from PyQt4.Qt import *
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
class A(QWidget):
def __init__(self,parnt=None):
super(A,self).__init__(parnt)
win=QWidget(self)
win.setWindowTitle(‘Age‘)
box=QSpinBox(self)
der=QSlider(Qt.Horizontal)
#有效范围
box.setRange(0,130)
der.setRange(0,130)
QObject.connect(box,SIGNAL(‘valueChanged(int)‘),der,SLOT(‘setValue(int)‘))
QObject.connect(der,SIGNAL(‘valueChanged(int)‘),box,SLOT(‘setValue(int)‘))
box.setValue(35)
layout=QHBoxLayout()
layout.addWidget(box)
layout.addWidget(der)
win.setLayout(layout)
app=QApplication(sys.argv)
a=A()
a.show()
sys.exit(app.exec_())
如图:
时间: 2024-11-25 23:02:52