Important: Please read the Qt Code of Conduct -

QGraphicsPathItem does not get hover events when mouse button is pressed

  • My item only gets hover events when the mouse button is not pressed. This is also true if the item is selected. How can I get hover events all the time?


  • I figured out that

    option->state & QStyle::State_MouseOver

    stays true if the mouse is pressed over an item and dragged. This happens even if I don't pass the mousePressEvent to the parent in this case. It seems that the scene is in some kind of move mode even though the item is not moveable.

  • Please Edit your Question and prepend [Solved]....

  • I will do that as soon as it is solved. What I added is just more information but as far away from a solution as it can be.

  • Sorry guys but it is completely unclear to me what happens while I drag the mouse. The only mouse-related events I get are mouseMove, mousePress and mouseRelease of the QGraphicsScene. There are no drag events, hover events or anything else. Not from the item where I start to drag, not from the view...nothing.

    I can drag items around if I set the correct flag but I don't want to drag this item. What I want to do is to change the colour of the item depending on some logic behind the scenes but without an event I would have to check the items under the mouse on every bit of movement and most of them are not colour changing ones so it would be a lot of overhead which is quite useless.

    I am happy to override every method in every class but I have to know where and I cannot find it.

    Any hints are more then welcome!

Log in to reply