Animating QGraphicsPixmapItem
I have 2 QImages(img1, img2) loaded in 2 QGraphicsPixmapItem(imgItem1, imgItem2)
Both are loaded in Graphics view
I'm overlaying the images
I want to create a small animation of QGraphicsPixmapItem within the graphicsview, when a button is clicked
such that it imgItem2 starts at rotation = 0 & rotates until a predefined rotation angle within 5seconds
then translates it by a predefined rowOffset and ColumnOffset within 5seconds
I can rotate & translate easily
but how do i create an animation of it with QTimer? QAnimation only works on objects like buttons/... not images?
looked at certain example sourc code, but i'm not winning
Please assist me
A basic example would be highly appreciated
Re: Animating QGraphicsPixmapItem
You can use QPropertyAnimation together with QSequentialAnimationGroup. Since the former can only animate properties, you need a subclass of QGraphicsItem that is derived from QObject. You can obtain that either by subclassing both QObject and QGraphicsPixmapItem, by subclassing QGraphicsObject and teaching it to show a pixmap or by wrapping a QGraphicsPixmapItem into QGraphicsObject.
Re: Animating QGraphicsPixmapItem
Thanks, though I want to create a small animation
is there no easier faster process
because its not a requirement of program
I just want to add a cool animated touch
Any ideas?
Re: Animating QGraphicsPixmapItem
Quote:
Originally Posted by
2lights
Thanks, though I want to create a small animation
How does a "small animation" differ from an "animation"?
Quote:
is there no easier faster process
because its not a requirement of program
I just want to add a cool animated touch
It's about 6 lines of code, if you're looking for something simpler, you need to define what "simplicity" means for you.