[Qt-interest] QGraphicsItem movement problem
Riccardo Roasio
riccardo.roasio at gmail.com
Mon Aug 23 08:46:27 CEST 2010
Thanks,
i will try both solutions!
2010/8/22 Konstantin Tokarev <annulen at yandex.ru>:
> 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