PDA

View Full Version : Obtaining base point position for text in QGraphicsTextItem



mangeshj
15th January 2011, 07:00
Hi,
I am using a QGraphicsTextItem in my scene to have full text editor functionality. However, I need to access the position of text baseline point. Is it possible to access the position of text base point from this graphics item. Please refer to the attached image file. I want the position of red dot in the figure from QGraphicsTextItem. I cannot use QGraphicsPathItem since I want text editor functionality.
Thanks,
Mangesh

d_stranz
15th January 2011, 15:33
I think QFontMetrics::ascent() or QFontmetrics::descent() will give you the information you want (in pixel coordinates). You'll then need to transform that into the world coordinates used by your QGraphicsTextItem and add it to the top left corner y coordinate of the bounding rect.