QWidget工程
1 #include "mywidget.h" 2 #include "ui_mywidget.h" 3 #include <QLabel> 4 #include <QPixmap> 5 #include <QMovie> 6 #include <QLCDNumber> 7 8 MyWidget::MyWidget(QWidget *parent) : 9 QWidget(parent), 10 ui(new Ui::MyWidget) 11 { 12 QLabel * lblText = new QLabel("真三国无双", this); 13 lblText->move(160, 2); 14 lblText->setStyleSheet("QLabel{font-family:微软雅黑; font-size:14pt}"); 15 lblText->setFrameShape(QFrame::Box); 16 lblText->setFrameShadow(QFrame::Sunken); 17 18 QLabel * lblPic = new QLabel(this); 19 lblPic->setPixmap(QPixmap("D:/a/res/pic/sanguo.jpg")); 20 lblPic->move(0, 30); 21 22 QLabel *lblGif = new QLabel(this); 23 lblGif->move(450, 120); 24 QMovie *m = new QMovie("D:/a/res/gif/mm.gif"); 25 lblGif->setMovie(m); 26 m->start(); 27 28 QLCDNumber *lcd = new QLCDNumber(8, this); 29 lcd->move(500, 40); 30 lcd->setSmallDecimalPoint(true);//显示小数点 31 lcd->setSegmentStyle(QLCDNumber::Flat); 32 lcd->setMode(QLCDNumber::Dec); 33 lcd->resize(170, 40); 34 lcd->display(3.14159); 35 36 37 ui->setupUi(this); 38 this->resize(800, 400); 39 } 40 41 MyWidget::~MyWidget() 42 { 43 delete ui; 44 }