PDA

View Full Version : Frame around a QGraphicTextItem



Orphelic
23rd August 2007, 13:48
Hello,

I try to program a QGraphicsTextItem, that acts like an editor. Therefore I need a permanent blinking text cursor. For making the QGraphicsTextItem to act like an editor, I use:


m_textItem->setTextInteractionFlags(Qt::TextEditorInteraction)

Here's the problem:
if this text item is active, there is always a dashed box around it. How can I prevent this box from being shown?

Thanks a lot

marcel
23rd August 2007, 13:55
Remove the ItemIsSelectable flag, but then it won't receive any focus.

Orphelic
23rd August 2007, 14:20
Remove the ItemIsSelectable flag, but then it won't receive any focus.
Thanks, but the problem is the blinking cursor...if I remove the focus, the cursor disappears.

Gopala Krishna
23rd August 2007, 14:34
This topic is discussed before.
Anyway answer in short is to derive your own text item and reimplement paint event like this

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

Justin_W
21st July 2008, 14:28
I meet a similar problem with QGraphicsItem : there's always a dashed box around my QGraphicsSvgItem whether it's selected or not.
Who can tell me why?