1 #include <QApplication>
 2 #include <QHBoxLayout>
 3 #include <QSlider>
 4 #include <QSpinBox>
 5 
 6 int main(int argc, char *argv[])
 7 {
 8     QApplication app(argc, argv);
 9 
10     QWidget *window = new QWidget;
11     window->setWindowTitle("Enter Your Age");
12 
13     QSpinBox *spinBox = new QSpinBox;
14     QSlider *slider = new QSlider(Qt::Horizontal);
15     
16     spinBox->setRange(0,130);
17     slider->setRange(0,130);
18 
19     QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
20     QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
21 
22     spinBox->setValue(35);
23 
24     QHBoxLayout *layout = new QHBoxLayout;
25     layout->addWidget(spinBox);
26     layout->addWidget(slider);
27     window->setLayout(layout);
28 
29     window->show();
30 
31     return app.exec();
32 }

 

相关文章:

  • 2021-06-18
  • 2019-02-28
  • 2019-03-04
  • 2021-11-04
  • 2021-04-19
  • 2021-11-06
  • 2021-05-29
  • 2021-06-09
猜你喜欢
  • 2021-05-31
  • 2021-09-05
  • 2020-03-19
  • 2021-11-05
  • 2021-08-29
  • 2021-04-21
  • 2021-04-25
  • 2021-10-03
相关资源
相似解决方案