QWidget工程
#include "mywidget.h" #include "ui_mywidget.h" #include <QLabel> #include <QPixmap> #include <QMovie> #include <QLCDNumber> MyWidget::MyWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MyWidget) { QLabel * lblText = new QLabel("真三国无双", this); lblText->move(, ); lblText->setStyleSheet("QLabel{font-family:微软雅黑; font-size:14pt}"); lblText->setFrameShape(QFrame::Box); lblText->setFrameShadow(QFrame::Sunken); QLabel * lblPic = new QLabel(this); lblPic->setPixmap(QPixmap("D:/a/res/pic/sanguo.jpg")); lblPic->move(, ); QLabel *lblGif = new QLabel(this); lblGif->move(, ); QMovie *m = new QMovie("D:/a/res/gif/mm.gif"); lblGif->setMovie(m); m->start(); QLCDNumber *lcd = , this); lcd->move(, ); lcd->setSmallDecimalPoint(true);//显示小数点 lcd->setSegmentStyle(QLCDNumber::Flat); lcd->setMode(QLCDNumber::Dec); lcd->resize(, ); lcd->display(3.14159); ui->setupUi(this); , ); } MyWidget::~MyWidget() { delete ui; }