Editable Text Item in Graphics
Unsolved
General and Desktop
-
I would like to create an editable text item in a graphics scene. It must be possible to retrieve the text value after loosing focus. I have found two Qt classes:
- QGraphicsTextItem allows editing by using QGraphicsTextItem::setTextInteractionFlags but it does not seem to have a function to get the text
- QGraphicsSimpleTextItem allows to get the text by using QGraphicsSimpleTextItem::text but it does not seem to have a way to make the text editable
I also do not immediately see how I can use a QLineEdit as part of a QGraphicsScene/QGraphicsView.
Anybody an idea of how I can create an editable text item in a QGraphicsScene/QGraphicsView from which I can get the text?
-
QGraphicsTextItem allows editing by using QGraphicsTextItem::setTextInteractionFlags but it does not seem to have a function to get the text
It has several methods to get the text: toPlainText(), toHtml() or document() if you want the whole rich text document.
As to how to add QLineEdit (or any other widget) into a scene see QGraphicsScene::addWidget().