[PyQt] exposedRect option passed to paint in subclass of QGraphicsItem

Antonio Valentino antonio.valentino at tiscali.it
Sun Jan 17 18:38:45 GMT 2010

Hi Buddy,

Il giorno Sun, 17 Jan 2010 11:14:29 -0700 (MST)
buddy+pyqt at nmt.edu ha scritto:

> I just updated my windows machine to the latest Qt and PyQt versions
> and I've been having a problem with my custom subclasses of
> QGraphicsItems.  When I reimplement the paint method it gets passed
> several option as a QStyleOptionGraphicsItem object. The exposedRect
> member of that is suppose to contain the area the needs to be
> repainted, however I always get a null rectangle.  Attached is a

starting from Qt 4.6 exposedRect should contain the bounding box of
the item unless you set the QGraphicsItem::ItemUsesExtendedStyleOptions:


> simple example I put together to illustrate the problem.  The example
> attached is suppose to draw a 3x3 rectangle under the mouse cursor
> when the mouse button is pressed down, but since the exposedRect is
> always null it does nothing.  It also prints out the rectangle and I
> always get lines of all zeroes.  I think this may be a bug, but
> please tell me if I'm just doing something wrong or if something is
> messed up with my PyQt install.

In your specific case I think you forgot to implement the boundingRect
method in yout custom QGraphicsItem.

Best regards

Antonio Valentino

More information about the PyQt mailing list