#include <QSpinBox> #include <QSlider> #include <QApplication> #include <QVBoxLayout> /////////////////////////////////////int main(int argc,char *argv[]){ QApplication app(argc,argv); QSpinBox *spin_box=new QSpinBox; spin_box->setMinimum(10); spin_box->setMaximum(100); spin_box->setSingleStep(5); QSlider *slider=new QSlider(Qt::Horizontal); slider->setRange(10,100); slider->setTickPosition(QSlider::TicksBelow); slider->setTickInterval(15); QObject::connect(slider,SIGNAL(valueChanged(int)), spin_box,SLOT (setValue(int)) ); QObject::connect(spin_box,SIGNAL(valueChanged(int)), slider,SLOT (setValue(int)) ); QWidget main_window; QVBoxLayout *main_layout=new QVBoxLayout(&main_window); main_layout->addWidget(spin_box); main_layout->addWidget(slider); main_window.show(); return app.exec();}