1. #include<QtGui> 
  2. int main(int argc,char* argv[]) 
  3.     QApplication app(argc,argv); 
  4.     QLabel *pLabel=new QLabel; 
  5.     QSlider *pSlider=new QSlider(Qt::Horizontal); 
  6.     QSpinBox *pSbin=new QSpinBox; 
  7.     QDialog *dialog=new QDialog; 
  8.     QVBoxLayout *vboxlayout=new QVBoxLayout; 
  9.     pSbin->setValue(50); 
  10.     pSlider->setValue(50); 
  11.     pLabel->setNum(50); 
  12.     vboxlayout->addWidget(pLabel); 
  13.     vboxlayout->addWidget(pSbin); 
  14.     vboxlayout->addWidget(pSlider); 
  15.     dialog->setLayout(vboxlayout); 
  16.     QObject::connect(pSlider,SIGNAL(valueChanged(int)),pSbin,SLOT(setValue(int)));//关联信号与槽函数 
  17.     QObject::connect(pSlider,SIGNAL(valueChanged(int)),pLabel,SLOT(setNum(int))); 
  18.     QObject::connect(pSbin,SIGNAL(valueChanged(int)),pSlider,SLOT(setValue(int))); 
  19.     dialog->show(); 
  20.     return app.exec();