[Qt-interest] Detect hand scrolling in QGraphicsItem::paint()

Stephen Chu stephen at ju-ju.com
Wed Nov 11 00:19:46 CET 2009


Just so people with the same issue can find this.

I ended up installing event filter watching GraphicsSceneMousePress and 
GraphicsSceneMouseRelease on the QGraphicsScene that contains this item. 
The mouse event handlers do not work for I need to accept the event in 
the pressed handler so the move and release events will reach the item. 
But this turns off hand dragging of the QGraphicsView completely, 
defeating the purpose.

In article <stephen-C6EA14.10323427102009 at nntp.trolltech.com>,
 Stephen Chu <stephen at ju-ju.com> wrote:

> That's it. Thanks a lot!
> 
> On 10/27/09 3:54 AM, Riccardo Roasio wrote:
> > Using this should be helpful?
> > 
> > virtual void *mouseMoveEvent 
> > <http://doc.trolltech.com/4.2/qgraphicsitem.html#mouseMoveEvent>* ( 
> > QGraphicsSceneMouseEvent * /event/ )
> > 
> > You can catch it and set something like a bool flag to true.
> > 
> > So you can test for the flag during painting...
> > 
> > Riccardo
> > 
> > 2009/10/26 Stephen Chu <stephen at ju-ju.com <mailto:stephen at ju-ju.com>>
> > 
> >     Is there a way to know if the current call to my paint() function is
> >     during a user hand scrolling?
> > 
> >     I am displaying a huge image and want the app to be responsive while
> >     user is drag-scrolling the image. The idea is to plot only a low-res
> >     version of the image while the user is dragging it around and repaint it
> >     with proper res one after the user let go of the button.
> > 
> >     So basically I need to know when the user starts and stops hand-dragging
> >     the QGraphicsView that contains my custom QGraphicsItem.
> > 
> >     Thanks.

-- 
Stephen Chu



More information about the Qt-interest-old mailing list