jano_alex_es
29th September 2009, 14:44
Hi,
I'm trying to have a QGraphicsTextItem on my scene, movable and editable. The desired behavior is: double click (select text and edit it), drag and drop. Like a normal text in any application, but being able to move it around.
I though that was possible with the next code, but the text doesn't change (is selected, I can copy and paste but nothing is written from the keyboard) and, when I set the text interaction flag, the item is not movable.
QGraphicsTextItem* textItem = new QGraphicsTextItem("test item");
textItem ->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsMovable);
textItem ->setTextInteractionFlags(Qt::TextEditorInteraction) ;
textItem ->setPos(100, 200);
m_pMyScene->addItem(textItem);
what could be wrong? thanks!
I'm trying to have a QGraphicsTextItem on my scene, movable and editable. The desired behavior is: double click (select text and edit it), drag and drop. Like a normal text in any application, but being able to move it around.
I though that was possible with the next code, but the text doesn't change (is selected, I can copy and paste but nothing is written from the keyboard) and, when I set the text interaction flag, the item is not movable.
QGraphicsTextItem* textItem = new QGraphicsTextItem("test item");
textItem ->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsMovable);
textItem ->setTextInteractionFlags(Qt::TextEditorInteraction) ;
textItem ->setPos(100, 200);
m_pMyScene->addItem(textItem);
what could be wrong? thanks!