Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, November 2006
Re: QGraphicsView misses updates


Message 1 in thread

Thanks for the hints.  I must be doing something wrong, because even your
hint did nothing.  Is this a problem that I am doing the updates to the
QGraphicsItem during a mouse move event?  What is odd is that if I move
items it will work just fine, its only when I try to draw a line from the
start point, to my current mouse point.

thx
        -ian reinhart geiser


Courtland Idstrom wrote:

> Are you calling QGraphicsView->update() -- I think this method
> doesn't invalidate regions that need repainting. You might want to
> use QGraphicsView::updateScene() instead. Are you relying on
> QGraphicsItem to send updates when necessary (I believe this is
> recommended and does work correctly)?
> 
> However, I have found that when lots of update rectangles are posted
> (which happens when many objects are moving at the same time),
> updates are very slow. I've submitted a bug report regarding this,
> but in the meantime, you can easily overcome this issue by overriding
> QGraphicsView::paintEvent() in your subclass with this:
> 
> void YourClass::paintEvent(QPaintEvent *event) {
> QPaintEvent adjusted = *event;
> 
> if(event->region().rects().size() > 10) {
> QRect rect = event->region().boundingRect().adjusted(-1,-1,1,1);
> adjusted = QPaintEvent(rect);
> }
> 
> QGraphicsView::paintEvent(&adjusted);
> return;
> }
> 
> When confronted with a large number of update rectangles, this sends
> only the boundingRect() of all regions posted in the paintEvent.
> 
> Cheers
> -Court
> 
> On Oct 30, 2006, at 11:40 AM, Ian Reinhart Geiser wrote:
> 
>> Dimitri wrote:
>>
>>> Hi,
>>>
>>>>         I have a problem with getting the QGraphicsView to
>>>> update.  It
>>>>         seems very
>>>> unreliable when I change the graphics item, and then call
>>>> update.  This
>>>> is most obvious when I am doing drag operations and need to
>>>> update the
>>>> objects
>>>> on the screen while the drag operation is in effect.  Does anyone
>>>> have
>>>> some hints on how to cause the graphics view to update without
>>>> bogging
>>>> down the system. (No update is a miserable failure)
>>>
>>> On which platform exactly?
>> WinXP (local & rdesktop), Linux (Ubuntu with Xorg 7.0.0, and SuSE
>> 10.1 with
>> Xorg 6.9), Win2K and Win2003 terminal services session.  I have not
>> tested
>> MacOSX yet, but should be able to do so tonight.
>> -ian reinhart geiser
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>

--
 [ signature omitted ] 

Message 2 in thread

Not sure if this is your problem or not but a long time ago I
had similiar problems because I was calling the View's update
instead of the canvas update (now called QGraphicsScene::update()).

Try calling the scene's ::update(sceneRect())

Jeff

On Tue, 2006-10-31 at 22:12 -0500, Ian Reinhart Geiser wrote:
> Thanks for the hints.  I must be doing something wrong, because even your
> hint did nothing.  Is this a problem that I am doing the updates to the
> QGraphicsItem during a mouse move event?  What is odd is that if I move
> items it will work just fine, its only when I try to draw a line from the
> start point, to my current mouse point.
> 
> thx
>         -ian reinhart geiser
> 
> 
> Courtland Idstrom wrote:
> 
> > Are you calling QGraphicsView->update() -- I think this method
> > doesn't invalidate regions that need repainting. You might want to
> > use QGraphicsView::updateScene() instead. Are you relying on
> > QGraphicsItem to send updates when necessary (I believe this is
> > recommended and does work correctly)?
> > 
> > However, I have found that when lots of update rectangles are posted
> > (which happens when many objects are moving at the same time),
> > updates are very slow. I've submitted a bug report regarding this,
> > but in the meantime, you can easily overcome this issue by overriding
> > QGraphicsView::paintEvent() in your subclass with this:
> > 
> > void YourClass::paintEvent(QPaintEvent *event) {
> > QPaintEvent adjusted = *event;
> > 
> > if(event->region().rects().size() > 10) {
> > QRect rect = event->region().boundingRect().adjusted(-1,-1,1,1);
> > adjusted = QPaintEvent(rect);
> > }
> > 
> > QGraphicsView::paintEvent(&adjusted);
> > return;
> > }
> > 
> > When confronted with a large number of update rectangles, this sends
> > only the boundingRect() of all regions posted in the paintEvent.
> > 
> > Cheers
> > -Court
> > 
> > On Oct 30, 2006, at 11:40 AM, Ian Reinhart Geiser wrote:
> > 
> >> Dimitri wrote:
> >>
> >>> Hi,
> >>>
> >>>>         I have a problem with getting the QGraphicsView to
> >>>> update.  It
> >>>>         seems very
> >>>> unreliable when I change the graphics item, and then call
> >>>> update.  This
> >>>> is most obvious when I am doing drag operations and need to
> >>>> update the
> >>>> objects
> >>>> on the screen while the drag operation is in effect.  Does anyone
> >>>> have
> >>>> some hints on how to cause the graphics view to update without
> >>>> bogging
> >>>> down the system. (No update is a miserable failure)
> >>>
> >>> On which platform exactly?
> >> WinXP (local & rdesktop), Linux (Ubuntu with Xorg 7.0.0, and SuSE
> >> 10.1 with
> >> Xorg 6.9), Win2K and Win2003 terminal services session.  I have not
> >> tested
> >> MacOSX yet, but should be able to do so tonight.
> >> -ian reinhart geiser
> >>
> >> --
> >> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> >> with "unsubscribe" in the subject or the body.
> >> List archive and information: http://lists.trolltech.com/qt-interest/
> >>
> >>
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]