Tracking the mouse position on the QGraphicsItem

password

I have a subclass of QGraphicsItem and I want to track mouse position every time I hover the mouse on that Item alone and it should give the relative position to the QGraphicsItem. I know, how to handle this when there is QWidget (using QWidget.setMouseTracking) and QMainWindow (by installing event filters), but I cant figure out how to do it for QGraphicsItem. The mouse move event is only triggered, when there is mouse press event, but that's not what is want. I want a trigger whenever I hover on that QGraphicsItem. Please provide your suggestions

three_pineapples

You will want to use my_item.setAcceptHoverEvents(True) to enable mouse move events without the mouse press event.

Note, this will not trigger a mouseMoveEvent but will instead trigger a hoverMoveEvent (along with hoverEnterEvent and hoverLeaveEvent when you initially move the mouse over or off the QGraphicsItem respectively. So make sure you override this method in your subclass of QGraphicsItem.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

tracking mouse position on Java WorldWind

jQuery UI .position() mouse event tracking with boundaries

How to make the picture not spin, but be in the same position when tracking the mouse movement

Resize a QGraphicsItem with the mouse

Get the position of a QWidget that is inside a QGraphicsItem

Tracking mouse coordinates in Qt

Tracking the mouse movement

How to make a QGraphicsItem's position dependent on another QGraphicsItem?

How to propagate mouse events to a QGraphicsItem in a QGraphicsItemGroup?

Resize about center on a QGraphicsItem proportional to mouse speed?

Qt: change QGraphicsItem receiver during mouse move

Paint on QGraphicsItem with mouse in PySide6

Tracking document position changes

How to find closer QGraphicsItem (in a QList) to the mouse x or the mouse y coords?

OpenGL Mouse Tracking (Freeform Line)

Time Tracking on mouse click Javascript

QGraphicsItem::itemChange notified for position change but not for size change

QGraphicsItem move event - get absolute position

Tracking scroll position of a component in React

Tracking position of points after piecewiseAffineTransformation

javascript draggable script tracking position

mouse position and give the position color

mouse position (Cursor.Position)

Weird behaviour of QToolTip when it should follow the mouse who is over a QGraphicsItem

Why are the QGraphicsItem's children not getting mouse clicks anymore if the item is selected?

How to get mouse hover events for shapes with a hole in a QGraphicsItem?

How to connect two QGraphicsItem by drawing line between them (using mouse)

KineticJS mouse position of image

Textarea mouse position issue

TOP Ranking

HotTag

Archive