zoukankan      html  css  js  c++  java
  • QT 等待对话框/进度--

    用QT的,加载的一张gif图片。记录下来以后免得忘记。

    [cpp] view plain copy
     
    1. #ifndef DIALOG_H  
    2. #define DIALOG_H  
    3.   
    4. #include <QDialog>  
    5. #include <QLabel>  
    6. #include<QPainter>  
    7. #include<QMovie>  
    8.   
    9. class Dialog : public QDialog  
    10. {  
    11.     Q_OBJECT  
    12.   
    13. public:  
    14.     explicit Dialog(QWidget *parent = 0);  
    15.     ~Dialog();  
    16.   
    17. private:  
    18.     QMovie *movie;  
    19.     QLabel *label;  
    20. };  
    21.   
    22. #endif // DIALOG_H  
    [cpp] view plain copy
     
    1. #include"dialog.h"  
    2.   
    3. Dialog::Dialog(QWidget*parent):  
    4.     QDialog(parent)  
    5. {  
    6.     label = new QLabel(this);  
    7.     this->setFixedSize(200,200);  
    8.     setWindowOpacity(0.5);  //设置透明用;  
    9.     this->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint);  
    10.   
    11.     //取消对话框标题  
    12.     //this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);  
    13.   
    14.     //取消对话框标题和边框  
    15.     //this->setAutoFillBackground(true);  
    16.     this->setContentsMargins(0,0,0,0);  
    17.     label->setContentsMargins(0,0,0,0);  
    18.     /*QPalettepalette;palette.setBrush(QPalette::Background,QBrush(QPixmap("E:/qml/imgdialog/loading.gif"))); 
    19.     this->setPalette(palette)*/;  
    20.     movie = new QMovie("loading.gif");  
    21.     label->setMovie(movie);  
    22.     movie->start();  
    23. }  
    24. Dialog::~Dialog()  
    25. {  
    26.     delete label;  
    27.     delete movie;  
    28. }  

    效果:

    loading.gif

    http://blog.csdn.net/wangwei890702/article/details/8590392

  • 相关阅读:
    Centos6.6部署Redis集群
    贪心算法解+-字符串
    水题记录--排序
    项目总结之HashMap问题
    水题记录--大整数求阶乘
    水题记录--组合数
    水题记录-成绩转换
    水题记录
    简单排序
    数组
  • 原文地址:https://www.cnblogs.com/findumars/p/7270329.html
Copyright © 2011-2022 走看看