PDA

View Full Version : Increasing the selection area for a qgraphicsPathitem



arjunasd
17th August 2007, 22:30
Hi all

I am having a problem with my QGraphicView framework. I want to select an QGraphcsPathItem by clicking on an an area surrounding the item. This area is +5 pixels on all sides on the item's bounding rect. I did the following:



QRectF boundingRect() const
{ return QGraphicsItem::boundingRect().adjusted(-5, -5, +5, +5); }

bool contains(const QPointF &point) const
{ return boundingRect().contains(point); }


The mouse click on the area surrounding the boundingRect is received by the item. I checked this by subclassing the mousePressEvent(). But the item is not getting selected this way. The item is a pathItem. So would it only get selected if clicked on the path?

Thanks
Arjun

jpn
17th August 2007, 23:03
I think you must reimplement QGraphicsItem::shape() and return a path containing the bounding rect.