Qt MouseMoveEvent only mouse click triggers

I have a strange problem here.

I am working on an application and in one of my classes I am tracking mouse events.

Strange, my mouse move event is fired only when any mouse button is clicked.

I don’t even filter any button presses inside the method; the method itself is not even called unless I click on this object (the one that tracks it).

What generally causes this type of error?

I'm not sure if this matters, but I have two different things that track my mouse inputs: 1) the main program that controls the global coordinates of the mouse, and 2) the object in my program that controls the coordinates of the mouse inside of me.

Edit So, the problem is that the mouse move event is usually used when people drag the screen to the right? My reason is not that this is because I am creating a custom sort context menu and I need to know when the item is hanging.

+6
source share
1 answer

Turns out I really didn't set everything in my class to enable mouse tracking. For some reason, I thought that if the class itself was configured to include it, I would not need to install it on all auxiliary objects, but now I see how this makes no sense at all.

So, just to clarify my solution: The elements that I need to track the position of the cursor should have

setMouseTracking(true); 
+9
source

Source: https://habr.com/ru/post/973600/


All Articles