QGraphicsItem::advance(int phase) how do they work
-
I looked at the "colliding mouse example":http://doc.qt.nokia.com/4.7-snapshot/graphicsview-collidingmice.html that ships with Qt. And QGraphicsItem Class Reference http://doc.qt.digia.com/4.6/qgraphicsitem.html#advance. Don't exactly understand the parameter int phase.
-
This function is called twice.
int parameter indicates phase.
If it 0 - it is called BEFORE any changes occur.
So you can prepare to change if you need.If it is 1 - function is called after the change occurred.
-
Ok :>
I understand advance work like a animation function, where each call simulate into a movement.Help me to interpret below function.
Silly Question:
1> how does this statement move the item at speed 5 ?? setPos(mapToParent(-(speed),0));2> why need mapToParent ?
'''
void BoxAnimation::advance(int phase)
{
if(!phase) return;
QPointF location = this->pos();
speed =5; //5 pixel per sec set in constructor.
setPos(mapToParent(-(speed),0));}