Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] How to convert and to forward a tap-and-hold gesture to QGraphicsTextItem to activate link
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to convert and to forward a tap-and-hold gesture to QGraphicsTextItem to activate link

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 1.2k 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 have a QGraphicsTextItem inside a custom QGraphicsObject.
    The custom QGraphicsObject grab various gesture in order to do various things.
    But when a TapAndHold gesture has been recognized I want to check is at that point on the underlying QGraphicsTextItem there is an hyperlink and active it (openUrl).

    How can I do that ?? Any suggestions ??
    My first idea was to create a QGraphicsSceneMouseEvent with the information with TapAndHold gesture and send it to QGraphicsTextItem... but I failed becaouse there is no constructor for creating a QGraphicsSceneMouseEvent.
    Any other options ??
    Is there a way to check and to extract the hyperlink from QGraphicsTextItem without event ??

    Thanks,
    Gianluca.

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

      I solved the problem.
      The solution is to get the QAbstractDocumentLayout from the QTextDocument returned by QGraphicsTextItem::document.

      With the QAbstractDocumentLayout there are various method to check the content under a point. One of them is anchorAt.
      So, in the handler for TapAndHold the following lines of code do the work:
      @ QString mayUrl = contacts->document()->documentLayout()->anchorAt( contacts->mapFromScene(tap->position()) );
      if ( !mayUrl.isEmpty() ) {
      qDebug() << "TRY TO OPEN" << mayUrl;
      QDesktopServices::openUrl( mayUrl );
      }
      @

      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