views:

69

answers:

2

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?

+1  A: 

http://doc.qt.nokia.com/4.6/qmovie.html

google and Qt docs are your friend. The Trolls even have an example

PS: unless you're in China, then google is unaccessible, but you'd have stuff like Bing and doc.qt.nokia.com

PS2: for a little more in-depth answer: you can use a QGraphicsProxyWidget of a QLabel which has a QMovie via QLabel::setMovie. There's probably an easier/shorter way to do it.

rubenvb
+2  A: 

Don't use GIF animation with QGraphicsView or QGraphicsScene, 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!

mosg
If someone asks you how much is 5x5 you say: "Don't ask how much is 5x5, you better ask how much is 2x2"? And you answer: "2x2 = 4"?
Narek
No, I say maybe 2x2=4 will help to get 25 from 5x5...
mosg
Yes, here the same story! You suggest me to calculate 5x5 by knowing 2x2=4 :))). I want to say thank you for your help but what you say I knew, I wanted to accomplish the task as I asked. May be you could help me to do this by using QGraphicsView and QGraphicsScene classes? Or if you say that it is impossble with these classes then it would be an answer too!
Narek
As I mentioned above, I don't have the final solution, and I really don't know is `QGraphicsView` class supports GIF animation. But still you could use another methods, like to create another `QThread` which would just show at the top of your main window GIF animation, while you app load scene or what ever... Oh, or it's 3x3?
mosg
+1 up-vote and I accept your answer, because, seems, this is the only way.
Narek