Advertisement

QT显示图片的几种方式

阅读量:

1 显示gif图片(label上显示)

在QT开发环境中,若需展示GIF格式的图像,仅依靠添加控件的方式无法实现。还需通过编写相应的代码来完成。所使用的开发工具为QT Creator。首先,创建一个新的工程项目,在designer界面中,我们应当添加一个QLabel控件。具体操作如下图所示:

将QLabel调整至合适的尺寸。

在对应的cpp类函数中插入以下代码段:

复制代码
 #include "widget.h"

    
 #include "ui_widget.h"
    
 #include <qmovie.h>
    
 Widget::Widget(QWidget *parent) :
    
     QWidget(parent),
    
     ui(new Ui::Widget)
    
 {
    
     ui->setupUi(this);
    
  
    
     QMovie *movie =new QMovie("D:/QT/project/qtcreaor/test/untitled/1.gif");

全部评论 (0)

还没有任何评论哟~