Chinaunix首页 | 论坛 | 博客
  • 博客访问: 80762
  • 博文数量: 24
  • 博客积分: 375
  • 博客等级: 一等列兵
  • 技术积分: 225
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-13 22:14
文章分类

全部博文(24)

文章存档

2014年(6)

2011年(18)

我的朋友

分类: LINUX

2011-04-03 22:03:44

//《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;
}

 
阅读(1284) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~