Animate an image in Qt
I have added an .png image to my QGraphics scene using addPixmap() . Now I want to animate that image. Means I want to move that image & it will be replaced with a new i开发者_如何学Gomage. Replace the old with new one show that it will look like moving.
addPixmap() will return a QGraphicsPixmapItem which you can move with setPos(). You can also change the pixmap with setPixmap().
You can do the animation manually using a timer to update the position and pixmap (with QTimer). There is a new animation framework in recent Qt releases which is documented here: http://doc.qt.io/qt-4.8/animation-overview.html
For me, I added into QLabel and moved it by QTimer on parent QWidget.
精彩评论