PDA

View Full Version : QGraphicsTextItem is not editable



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!

scascio
29th September 2009, 15:43
the code provided works for me, but I had to change pruebaTexto with textItem.

jano_alex_es
29th September 2009, 15:51
sorry, my bad, I'll edit the text.


So my error is somewhere else... thanks, I'll take a look.