3

I am trying to use one blinking image in QGraphicsPixmapItem. The image has shown without the animation effect. The below is the original image, the following is the QGraphicsScene which uses this image in QGraphicsPixmapItem. Can anybody say how to achieve this?.

enter image description here

enter image description here

prabhakaran
  • 5,126
  • 17
  • 71
  • 107
  • possible duplicate of [GIF animation in Qt](http://stackoverflow.com/questions/3248243/gif-animation-in-qt) – Mat Apr 24 '11 at 09:41
  • @Mat Thank you for your suggestion. But that answer can't serve my purpose. Because there is no way to add QMovie to QGraphicsPixMapItem. – prabhakaran Apr 24 '11 at 09:53
  • 1
    Indeed, but you can make a QGraphicsProxyWidget from a QLabel and put that in your scene instead of the QGraphicsPixmapItem. This is also listed in the answers to the question linked above. – Mat Apr 24 '11 at 09:57
  • @Mat thank you. That worked very well except the background is not transparent. – prabhakaran Apr 24 '11 at 10:19

1 Answers1

5

Check this answer from Nosf on this thread:

I guess you could add a QGraphicsProxyWidget to your scene

set a QLabel to the ProxyWidget and then set the label to use your gif as a QMovie.

QGraphicsScene scene;
QLabel *gif_anim = new QLabel();
QMovie *movie = new QMovie(image);

gif_anim->setMovie(movie);
movie->start();

QGraphicsProxyWidget *proxy = scene.addWidget(gif_anim);