//《24小时学通qt编程》
#include
#include
#include
#include
#include
#include
#include
class MyMainWindow:public QWidget
{
public:
MyMainWindow();
private:
QPushButton *b1;
QLabel *label;
QLCDNumber *lcd;
QSlider *slider;
};
MyMainWindow::MyMainWindow()
{
//Orientation Vertical;
setGeometry(100,300,300,350);
b1=new QPushButton("Quit",this);
b1->setGeometry(20,20,160,80);
b1->setFont(QFont("Times", 18, QFont::Bold));
lcd=new QLCDNumber(2,this );
lcd->setGeometry(100,150,150,100);
slider=new QSlider(Qt::Vertical,this);
slider->setGeometry(10,150,80,130);
label=new QLabel(this);
label->setGeometry(20,110,160,50);
label->setText("This is the first line\n This is the second line");
// label->setAlignment(AlignCenter);
//label->setAlignment(AlignCenter);
connect(b1,SIGNAL(clicked()),qApp,SLOT(quit()));
connect(slider,SIGNAL(valueChanged(int)),lcd,SLOT(display(int)));
}
int main(int argc,char **argv)
{
QApplication a(argc,argv);
MyMainWindow w;
//a.setMainWidget(&w);
w.show();
a.exec();
return 1;
}
阅读(1316) | 评论(0) | 转发(0) |