PDA

View Full Version : How to insert an animated picture (GIF) in a QLabel or other



AngiSad
13th January 2010, 12:30
I have been trying to insert an animated picture GIF in a QLabel. I searched in Google to see how to do it (I am a newbie :p)
I used this code:


#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QLabel w;

// On crée une vidéo. Ici, c'est un GIF
QMovie movie("c:/Mickey-11.gif");
// On l'associe à un label
w.setMovie (&movie);
// On lance la vidéo
movie.start ();

w.show();
return app.exec();
}

(from http://qt.developpez.com/faq/?page=animation#gif_anime)

but it is not working. They mentioned compiling the GIF plugin but I didn't know how to do it.

Thanx for your help :o

JD2000
13th January 2010, 13:04
You need a QMovie pointer in line 9
try
QMovie *movie = new QMovie("c:/Mickey-11.gif");

AngiSad
13th January 2010, 14:53
I tried that but still nothing :(

JD2000
13th January 2010, 16:24
You should have something like this:


QLabel *w = new QLabel(this);
w->setFrameStyle(QFrame::Panel | QFrame::Sunken);
QMovie *movie = new QMovie("c:/Mickey-11.gif");
w->setMovie (movie);
movie->start ();

high_flyer
13th January 2010, 17:05
please don't cross-post
http://www.qtcentre.org/threads/27208-How-to-insert-an-animated-picture-(GIF)-in-a-QLabel