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] Tracking mouse move in a QGraphicsItem subclass
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Tracking mouse move in a QGraphicsItem subclass

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k 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.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    Greetings.

    I'm implementing event handlers in a subclass of QGraphicsItem. Under certain circumstances (defined by a flag values​​) I want that the cursor changes its shape (Qt::SizeVerCursor, Qt::SizeHorCursor, Qt::SizeBDiagCursor, Qt::SizeFDiagCursor and Qt::ArrowCursor) when being moved (without any mouse button being pressed) to certain parts of my QGraphicsItem subclass.

    I would like some idea about it, particularly as thought I can do to "activate" or "simulate" functionality similar to QWidget::setMouseTracking(bool enable), but for QGraphicsItem... I think I need it to perform the task arising above.

    Thanks for any help and/or suggestions.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      you should have a look at setAcceptHoverEvents and friends from QGraphicsItem

      Hope it helps

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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        isaacEnrique
        wrote on last edited by
        #3

        Thanks for the advice SGaist.

        I put 'setAcceptsHoverEvents (true)' and implement event handlers

         void hoverEnterEvent (QGraphicsSceneHoverEvent * event);
         void hoverMoveEvent (QGraphicsSceneHoverEvent * event);
         void hoverLeaveEvent (QGraphicsSceneHoverEvent * event);
        

        And I achieved complete the task.

        Isaac Pérez
        Programming is understanding.

        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