[SOLVED] Tracking mouse move in a QGraphicsItem subclass



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


  • Lifetime Qt Champion

    Hi,

    you should have a look at setAcceptHoverEvents and friends from QGraphicsItem

    Hope it helps



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


Log in to reply
 

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