Results 1 to 2 of 2

Thread: Obtaining base point position for text in QGraphicsTextItem

  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    1

    Default Obtaining base point position for text in QGraphicsTextItem

    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
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Obtaining base point position for text in QGraphicsTextItem

    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.

Similar Threads

  1. QGraphicsTextItem and text cursor position via QPoint
    By Lykurg in forum Qt Programming
    Replies: 2
    Last Post: 10th July 2017, 19:38
  2. QGraphicsTextItem position
    By harmodrew in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2010, 22:03
  3. QGraphicsTextItem not remembering it's position
    By grabalon in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2010, 16:55
  4. Word at mouse click position in QGraphicsTextItem
    By pherthyl in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2008, 05:56
  5. Replies: 3
    Last Post: 14th April 2006, 12:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.