QGraphicsView improper animation



  • Hey there,

    I'm working with the QGraphicsView and QGraphicsScene. Until now, I was just setting up a static scene with some basic functions that allow to move and scale items. Now I tried to set up a simple animation where an item starts to move around. I searched for some tutorials and examples and found out, that there are a lot of suggestions to just setup a QTimer and refresh the position of the item every timeout.

    So I did this and adjusted the timer interval to about 16ms which should match more or less to the monitor refresh rate at 60Hz. First question here, is there any possibility to match the animation to the exact refresh rate of the monitor?

    The moving item, a simple QGraphicsRectItem, is moved in front of a QPixmap. But although I set the ZValue of the rectangle to the front, it disappears from time to time during the animation. The animation seems to be kind of instable at all, so if I move the scene around with the scrollbars, the moved item starts generate a tail of old positions of the item.
    So here is where I start to ask myself, is there a better way to do simple animations like moving an item around the scene?

    As always, I appreciate any kind of help very much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.