PDA

View Full Version : Animated GIF Problem



MSUdom5
23rd February 2010, 18:58
This one is really giving me a headache. I'm loading an animated gif and setting it as a movie in a QLabel.




QMovie *status_gif = new QMovie("status.gif");

if (!status_gif->isValid()) {
QMessageBox::information(this, "Error", "This Sucks...");
}

status_gif->start();

_status_animation = new QLabel();
_status_animation->setMovie(status_gif);
_status_animation->setFixedSize(31,31);
status_layout->addWidget(_status_animation);



This works great on my machine (the one I wrote the code on), but on any other machine I try, isValid() fails. The file exists in the correct place (current directory), I've checked a hundred times. Any clue as to what could cause a gif not to load?

Lykurg
23rd February 2010, 19:01
Any clue as to what could cause a gif not to load?
Yes, you forgot to deliver the gif image plugin with your application. (My crystal ball says I am 99,9999% right with that assumption)

MSUdom5
23rd February 2010, 19:18
Thanks for the reply. I'm sure you're crystal ball is right, but what's the correct way to deliver this plugin? I'm assuming it's the .\qt\plugins\imageformats\qgif4.dll file. I include this in the directory, but the gif still doesn't load.

boudie
23rd February 2010, 20:41
Are you really sure about the current directory?
Try giving a full absolute path to the gif-file.

MSUdom5
23rd February 2010, 21:09
Thanks boudie. Yeah, I'm sure, and I've tried using an absolute path. I'm convinced it's the plugin issue as Lykurg mentioned. Here's some new info:

On my development machine, I moved the gif plugin from '\qt\plugins\imageformats' to a new directory called '\qt\plugins\imageformats\temp'. This, of course, causes the gif not to be loaded. However, when I move the plugin dll to the executable directory, the gif still isn't loaded. Where does this plugin dll need to be (relative to the executable directory), in order to be seen?

I've also tried using 'Application::addLibraryPath()' to force it to look in a certain directory, but that doesn't work either.

Lykurg
23rd February 2010, 23:30
Hi, you can find the path informations there: http://doc.trolltech.com/4.6/deployment-windows.html. But to be honest, I am struggle each time with that. So try various directories till it success. As I remember it has to be (root is the application execution directory) \plugins\imageformats\qgif4.dll orsimple \plugins\qgif4.dll

aamer4yu
24th February 2010, 06:04
If your application is in say #APP_DIR#, then you should copy the imageformats folder to #APP_DIR#.
#APP_DIR#/ImageFormats will be the new location. The gif dll will be inside Imageformats directory as per the structure in qt directory.

MSUdom5
24th February 2010, 13:28
aamer4yu, that fixed it! Thanks!

The documentation didn't seem to explain this very well. Intuitively, I would think the dll should go in $APP_DIR/plugins/imageformats as Lykurg mentioned. Does the required dll location change between Qt releases?

aamer4yu
24th February 2010, 17:24
Does the required dll location change between Qt releases?
I dont think so.

Abhijeet Kumar
25th January 2016, 06:29
Thanks for the post...very helpful..saved lot of time.