Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QGraphicsView - track mouse position without press?



  • Hey

    I have few qGraphicItems in my scene/view. I'd like to enlarge them if mouse is within x distance from the item. So that pressing on them is easier in case they are small.

    Can any1 suggest how I can track the mouse in graphic view & more ?

    I tried getting mouseMoveEvent and then somehow see if there is a "visible items" array in view to loop over to check their position/distance from mouse. But the mouseMoveEvent don't get fired till the mouse button is pressed so that did not work.

    What other events can I use? Do I need to installe some event filter?


  • Qt Champions 2017

    you need to enable the mouseTracking with setMouseTracking(true) for graphicsView. Then you can track the mouseMovment without press and move. Use setAcceptHoverEvents(..) on GraphicsItem


Log in to reply