[Qt-interest] QGraphicsItem movement problem
Konstantin Tokarev
annulen at yandex.ru
Sun Aug 22 18:06:50 CEST 2010
On Thu, 15 Jul 2010 15:00:57 +0200
Riccardo Roasio <riccardo.roasio at gmail.com> wrote:
> Hi,
>
> i'm implementing a movement of a QGraphicsItem due to mouse press and
> movement..
>
> currentMovement=event->pos().x();
>
> if(currentMovement<startMovement)
> {
> //movememnt is right to left
> int delta=startMovement-currentMovement;
> currentX=startX-delta;
>
> std::cout<<"DELTA : "<<delta<<std::endl;
> std::cout<<"currentX : "<<currentX<<std::endl;
>
> setPos(currentX,startY);
> update();
> }
>
>
> the problem is that the effect is not so fluid, but the continuous
> refresh create a blinking effect of the item..
>
> I can i solve this problem?
If you still didn't found a solution, I can suggest the next things:
1) pass appropriate QRegion as argument of update - this will update
only changed region of scene. You can construct QRegion as (new are of
object) + (previous area of object)
2) use repaint() instead of update() - it will trigger immediate
repaint, while update() tries to merge several paint events into one
--
Regards,
Konstantin
More information about the Qt-interest-old
mailing list