BTW i had a look at the source code of QPainterPathItem and actually that draws the bounding rect. So the above solution will be drawing the bounding rect twice 
You can use this hack instead
{
QStyle::State back
= o
->state;
o
->state
&= ~
QStyle::State_Selected;
//Removes selection flag o->state = back;
if(o
->state
& QStyle::State_Selected) p->setPen(selectedPen);
else
p->setPen(unselectedPen);
p->drawRect(boundingRect());
}
MyPathItem::paint(QPainter *p, QStyleOptionGraphicsItem *o, QWidget *w)
{
QStyle::State back = o->state;
o->state &= ~QStyle::State_Selected;//Removes selection flag
QGraphicsPathItem::paint(p,o,w);
o->state = back;
if(o->state & QStyle::State_Selected)
p->setPen(selectedPen);
else
p->setPen(unselectedPen);
p->drawRect(boundingRect());
}
To copy to clipboard, switch view to plain text mode
Bookmarks