Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIF animation in Qt

I have used QGraphicsView, QGraphicsScene classes in order to show a picture in a widget like this:

m_Scene->addPixmap(QPixmap(fileName)); m_View->setScene(m_Scene); 

How I can show .gif animation in the same scene?

like image 627
Narek Avatar asked Jul 14 '10 16:07

Narek


People also ask

How do you put a GIF in Qt?

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.

How do I use QMovie?

To start the movie, call start() . QMovie will enter Running state, and emit started() and stateChanged() . To get the current state of the movie, call state() . Whenever a new frame is available in the movie, QMovie will emit updated() .


1 Answers

I don't use GIF animation with QGraphicsView or QGraphicsScene, I use it only in QDialog, but I think it's the same stuff, so here is my code:

QMovie *movie = new QMovie(":/images/other/images/16x16/loading.gif"); QLabel *processLabel = new QLabel(this); processLabel->setMovie(movie); movie->start(); 

My loading.gif I took from this link.


PS: also check the examples from Qt SDK. They are really can help!

like image 158
mosg Avatar answered Sep 19 '22 14:09

mosg