PDA

View Full Version : Elegant way of getting if element is focused in function QGraphicsItem::shape()



tuxit
1st August 2011, 16:28
hello,

i can learn if my object inherits from QGraphicsItem is focused in paint method:


void MyQGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
if (option->state & QStyle::State_HasFocus) {
//if focus some shape

} else {
//if no focus another shape
}
}

but i must click it and the shape must change whether it is focused or not.
how can i get if focused information in


QPainterPath QGraphicsItem::shape() const

method in an appropriate way?
I think to declare a global variable but i do not like this idea.
thanks

MarekR22
2nd August 2011, 11:54
strange: why you couldn't find: QGraphicsItem::hasFocus