Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved How to enable mouse tracking for QGraphicsItem?

    General and Desktop
    qgraphicsitem
    2
    3
    385
    Loading More Posts
    • 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.
    • Alex SUNPP
      Alex SUNPP last edited by

      I have multiple QGraphicsItem set in QGraphicsScene. I want mouseMoveEvent (QGraphicsSceneMouseMoveEvent *event) for these objects to trigger without mousePressEvent(). A documentation clearly says that this behavior is realised by setting setMouseTracking(true) for the widget.
      But the problem is that I don't see any QWidget object inside QGraphicsItem and QGraphicsScene. Where should I put setMouseTracking? Any help will be appreciated.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You can have something similar using the hovering related methods. See QGraphicsItem setAcceptHoverEvents for more details.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Alex SUNPP 1 Reply Last reply Reply Quote 0
        • Alex SUNPP
          Alex SUNPP @SGaist last edited by

          @SGaist yes, hovering will be okay too. I just didn't think that constant mouse tracking is such a problem.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post