Straight to the point
I have multiple QLabel widgets inside QVBoxLayout.
When I press left mouse button and start dragging (I don’t actually drag any widgets, I only move the mouse cursor while left mouse button is being pressed), one of the QLabels receives the mousePressEvent, and all subsequent mouseMoveEvents are sent to that QLabel which received the mousePressEvent, even when the mouse cursor has moved outside of the bounding box of this QLabel.
This does not work for me. I want the original QLabel which first received the mousePressEvent to stop receiving mouse events if the event occurred outside of the QLabel’s bounding box. If it happens, I want the other QLabel (to where the cursor has moved) to start handling the mouse events.
Setting mouse tracking to true did not help, “locking” still happens.
Any suggestions? Thanks <3
Some background
What I am actually implementing is text selection mechanism for my document viewer application.
Pixmaps are obtained from pages of a document and set as QLabels’ pixmaps.
When a mousePressEvent occurs selection starts and continues on the following onMouseMove events. But when I want to select text from multiple pages and I move the mouse cursor to another QLabel, events are still being sent to that original QLabel. This is the issue. I have perfectly functioning selection mechanism for a single page. The issue arose just now when I realized that mouse events work this way in Qt.