Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Extract text block from QGraphicsTextItem based on QPointF
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Extract text block from QGraphicsTextItem based on QPointF

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 947 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GianlucaG Offline
    GianlucaG Offline
    Gianluca
    wrote on last edited by
    #1

    Dear all,
    I'm trying to find out a way to extract the word at position <x,y> of a QGraphicsTextItem.
    I looking for a method on the documentation, but it seems that there is no method that return the character or the word given a <x,y> position.

    Any suggestions ??

    Thanks,
    Gianluca.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      Have you taken a look at QAbstractTextDocumentLayout::hitTest?

      I have never tried this, but you can get a QAbstractTextDocumentLayout from the QTextDocument, and the QTextDocument from the QGraphicsTextItem. Should work, if you transform the coordinates correctly.

      1 Reply Last reply
      0
      • GianlucaG Offline
        GianlucaG Offline
        Gianluca
        wrote on last edited by
        #3

        Yes !! Thank you.
        You solved two problems... the one of this thread, and another that I posted in another thread :-)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved