我的第一个QT程序

1600阅读 0评论2014-09-24 vibe26
分类:其他平台


点击(此处)折叠或打开

  1. #include<QApplication>
  2. #include<QHBoxLayout>
  3. #include<QSlider>
  4. #include<QSpinBox>

  5. int main(int argc,char *argv[])
  6. {
  7.     QApplication app(argc,argv);

  8.     QWidget *window=new QWidget;
  9.     window->setWindowTitle("Enter Your Age");

  10.     QSpinBox *spinBox=new QSpinBox;
  11.     QSlider *slider=new QSlider(Qt::Horizontal);
  12.     spinBox->setRange(0,130);
  13.     slider->setRange(0,130);

  14.     QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
  15.     QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
  16.     spinBox->setValue(35);

  17.     QHBoxLayout *layout=new QHBoxLayout;
  18.     layout->addWidget(spinBox);
  19.     layout->addWidget(slider);
  20.     window->setLayout(layout);

  21.     window->show();

  22.     return app.exec();
  23. }
上一篇:12864显示屏驱动代码
下一篇:fedora安装配置qtcreator