主要学习简单的 Wdiget 的添加问题…
main.cpp
| #include <QtGui/QApplication>#include<QSpinBox>
 #include<QSlider>
 #include<QHBoxLayout>
 int main(int argc, char *argv[])
 {
 QApplication a(argc, argv);
 
 QWidget *widget=new QWidget;
 widget->setWindowTitle("input your age");
 
 QSpinBox *spinBox=new QSpinBox;
 spinBox->setRange(0,130);
 
 QSlider *slider=new QSlider(Qt::Horizontal);
 slider->setRange(0,130);
 
 QObject::connect(spinBox,SIGNAL(vauleChanged(int)),slider,SLOT(setValue(int)));
 QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
 
 spinBox->setValue(0);
 
 QHBoxLayout *layout=new QHBoxLayout;
 layout->addWidget(spinBox);
 layout->addWidget(slider);
 widget->setLayout(layout);
 widget->show();
 return a.exec();
 }
 
 | 
运行结果

PS:居然 connect 中 sender 的函数打错了还能用….好囧啊