use QGraphicsTextItem
I also add the following code to make it editable:
QVariant MyTextEdit
::itemChange(GraphicsItemChange change,
const QVariant &value
) {
switch (change) {
case ItemSelectedHasChanged:
if (value.toBool()) { // selected
setTextInteractionFlags(Qt::TextEditorInteraction);
} else { // deselected
setTextInteractionFlags(Qt::NoTextInteraction);
}
break;
default:
break;
}
}
QVariant MyTextEdit::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case ItemSelectedHasChanged:
if (value.toBool()) { // selected
setTextInteractionFlags(Qt::TextEditorInteraction);
} else { // deselected
setTextInteractionFlags(Qt::NoTextInteraction);
}
break;
default:
break;
}
return QGraphicsTextItem::itemChange(change, value);
}
To copy to clipboard, switch view to plain text mode
Bookmarks