[SOLVED] Extract text block from QGraphicsTextItem based on QPointF



  • 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.



  • 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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.