PDA

View Full Version : Hide the focus rectangle of a QGraphicsLineItem



ronno
16th June 2009, 11:01
I'm deriving a class from QGraphicsLineItem, where I've set it to be selectable, i.e.,

class Link : public QGraphicsLineItem
{
// constructor
Link() { ...
setFlags (QGraphicsItem::ItemIsSelectable);
}
}

How can I make it's focus rectangle either transparent or turn it off with a flag?

Thanks,
Ron

rajesh
16th June 2009, 11:41
where you using line object?
use setFocus
e.g:
Line ln;
ln.setVisible();
ln.setFocus();

Lykurg
16th June 2009, 11:47
Next time please try to use our search engine first, because that issue has discussed sometimes before:


void Link::paint(QPainter *p, const QStyleOptionGraphicsItem *o, QWidget *w)
{
QStyleOptionGraphicsItem *_o = const_cast<QStyleOptionGraphicsItem*>(o);
_o->state &= ~QStyle::State_Selected;
QGraphicsLineItem::paint(p,_o,w);
}