QT 等待对话框/进度--
用QT的,加载的一张gif图片。记录下来以后免得忘记。
[cpp]
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
#include <QLabel>
#include<QPainter>
#include<QMovie>
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
QMovie *movie;
QLabel *label;
};
#endif // DIALOG_H
[cpp]
#include"dialog.h"
Dialog::Dialog(QWidget*parent):
QDialog(parent)
{ www.zzzyk.com
label = new QLabel(this);
this->setFixedSize(200,200);
setWindowOpacity(0.5); //设置透明用;
this->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint);
//取消对话框标题
//this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
//取消对话框标题和边框
//this->setAutoFillBackground(true);
this->setContentsMargins(0,0,0,0);
label->setContentsMargins(0,0,0,0);
/*QPalettepalette;palette.setBrush(QPalette::Background,QBrush(QPixmap("E:/qml/imgdialog/loading.gif")));
this->setPalette(palette)*/;
movie = new QMovie("loading.gif");
label->setMovie(movie);
movie->start();
}
Dialog::~Dialog()
{
delete label;
delete movie;
}
效果:
补充:软件开发 , C++ ,