使用Qt显示GIF格式动画

来源:互联网 发布:linux装mysql数据库 编辑:程序博客网 时间:2024/06/05 17:42

I put this here in case someone other than me runs into the same problem.

Problem

The GIF would not load and isValid() returns false.

Code

// Load animated GIFQMovie* movie = new QMovie("foo.gif");// Make sure the GIF was loaded correctlyif (!movie->isValid()) {    // Something went wrong :(}// Play GIFQLabel* label = new QLabel(this);label->setMovie(movie);movie->start(); 

Solution

To solve this, I had to put Qt's GIF-plugin qgif4.dll in a folder named imageformats next to my exe to be able to use GIFs.

The dll can be found under /plugins/imageformats/qgif4.dll

0 0
原创粉丝点击