1,#include<QApplication>#include<Qlabel>intmain(intargc,char*argv[]){QApplicationapp(argc,argv);//QLabellbInfo("Hello,World",0);QLabel*lbInfo=newQLabel("Hello,World",0);//lbInfo.show();lbInfo->show();returnapp.exec();}2,#include<QApplication>#include<QPushButton>intmain(intargc,char*argv[]){QApplicationapp(argc,argv);//QPushButtonbtnOk("OK",0);QPushButton*btnOk=newQPushButton("OK",0);btnOk->resize(300,200);QObject::connect(btnOk,SIGNAL(clicked()),&app,SLOT(quit()));//信号与槽联系起来btnOk->show();returnapp.exec();}3,#include<QApplication>#include<QWidget>#include<QSlider>#include<QSpinbox.h>intmain(intargc,char*argv[]){QApplicationapp(argc,argv);QWidget*centralwidget=newQWidget(0);QSpinBox*spBox=newQSpinBox(centralwidget);QSlider*slider=newQSlider(Qt::Horizontal,centralwidget);spBox->setGeometry(QRect(20,20,44,22));slider->setGeometry(QRect(90,20,160,21));spBox->setRange(0,140);slider->setRange(0,140);QObject::connect(spBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));//信号与槽联系起来QObject::connect(slider,SIGNAL(valueChanged(int)),spBox,SLOT(setValue(int)));//信号与槽联系起来spBox->setValue(32);centralwidget->show();returnapp.exec();}