PDA

View Full Version : Text mark on Scene



lni
11th April 2011, 07:43
Hi,

I need to add a text mark on to a graphics scene, just like Words, or the attached picture.

Does anyone know if there is a free such QGraphicsItem around?

Thanks!

high_flyer
11th April 2011, 15:39
No - you will have to make one your self, based on the basic graphic items available.

lni
12th April 2011, 05:11
Hi,

I need to add a text mark on to a graphics scene, just like Words, or the attached picture.

Does anyone know if there is a free such QGraphicsItem around?

Thanks!

This is very basic and useful Item, I wonder why Qt doesn't provide this item. I do hope somewhere I can just download it..

high_flyer
12th April 2011, 09:10
What is so basic or common a bout it?
Where except in your application and maybe comics applications you might see something like that?

JohannesMunk
12th April 2011, 12:03
Not a GraphicsItem, but you could show a QWhatsThis (http://doc.qt.nokia.com/latest/qwhatsthis.html) at the appropriate position. It's like a hint, but stays visible, until the user clicks somewhere.

Otherwise, really just implement this yourself. Inherit from QGraphicsItem. Introduce text and size attributes and a position for the starting point of the text mark. Whenever an updated is required (due to attribute changes or on first show) create a QPainterPath (http://doc.qt.nokia.com/latest/qpainterpath.html) for your bubble, using arcTo and lineTo. Return that as shape of your item and its boundingRect as boundingrect.. You can draw the path and the text in the paintEvent of your item using the QPainter (http://doc.qt.nokia.com/latest/qpainter.html).

HIH

Joh