PDA

View Full Version : how can I make a balloon to wrap the editable text?



learning_qt
19th January 2009, 14:42
I hope to add some editable texts wrapped by a balloon in QGraphicsScene.

1. Which QT class will be the class to make this balloon and balloon's shape can be changed ?
2. I also hope to insert this balloon to QGraphicsScene with the specified position, how can I do?

Thanks!

wysota
19th January 2009, 15:34
1. Which QT class will be the class to make this balloon and balloon's shape can be changed ?
QGraphicsPathItem or QGraphicsRectItem, depending on what you want to achieve.

You will also have to create a QGraphicsTextItem as a child of that item to have editable text inside the baloon.


2. I also hope to insert this balloon to QGraphicsScene with the specified position, how can I do?

Use QGraphicsItem::setPos().

aamer4yu
20th January 2009, 05:26
There was a related shaped text example in Qt Quarterly(qq24 i guess). You can search for it.

learning_qt
20th January 2009, 08:11
Hello wysota

I am not clear about your idea.

You will also have to create a QGraphicsTextItem as a child of that item to have editable text inside the baloon.

I will use QLineEdit to edit the text. It is a QWidget.

How can I create a QGraphicsTextItem as a child from the QLineEdit?

Could you please give some code example?

Thanks!

wysota
20th January 2009, 08:56
Why do you want to put a QLineEdit inside a graphics scene?

learning_qt
20th January 2009, 09:09
I hope to input some texts to the image. And those texts can be editable.

The idea is like this:

I insert one QImage in QGraphicsScene.
I hope to add some text to this QGraphicsScene, for example, "It is taken in Norway". And those texts can be edited.
After saving, the texts and image will be merged.

Thanks!

aamer4yu
20th January 2009, 09:17
You can edit text in QGraphicsTextItem.
Have a look at Diagram Scene example in Qt Demo-->GraphicsView section

wysota
20th January 2009, 09:17
But you don't need a QLineEdit for that :) Use QGraphicsTextItem as suggested.

learning_qt
20th January 2009, 14:46
Thanks!

I started to use QGraphicsTextItem
But I still can not add one editable area to QGraphicsScene

i did like this. I am sure there are something missing, but I don't know what?


QGraphicsTextItem textItem =new QGraphicsTextItem();
textItem->setTextInteractionFlags(Qt::TextEditorInteraction) ;
textItem->setZValue(1000.0);
imageScene->addItem(textItem);
textItem->setPos(200,300);

wysota
20th January 2009, 16:09
You are missing an asterisk in the declaration of the item. Also set the ItemIsFocusable flag on the item.