View Full Version : QPushButton mouse events

14th January 2006, 23:09
Something that's irritating me slightly:
In an application I'm writing, I've subclassed QPushButton to add a mouseMoved() signal. However, there's a tiny border around the edge of the button, about a pixel on every side, where the mouse doesn't trigger QPushButton::mouseMoveEvent(); yet, if the user clicks, clicked() and friends are emitted. Is there any way around this?

15th January 2006, 13:11
Are you sure that this is a border and not a 1px area that is maybe caused by the fact that a move from outside in the first pixel of the button is not realy a move but a mouseEnter? You can test this by moving the mouse in this border, maybe up and down in the left or right border. If you get mouseEnter and mouseLeave-events for the cases you miss a mouseMoveEvent, you can just use these.

15th January 2006, 13:29
Aha. That was indeed the problem. Overriding enterEvent(QEvent*) worked. Thank you.

15th January 2006, 14:05
A similar problem: what about accepting mouse events if the button(s) is/are held down? When the buttons are held down as the mouse enters the widget, it seems no events are fired; even hasMouse() returns false. I've tried the drag* events, but no joy.

15th January 2006, 16:42
I think the widget where you actually pressed the mouse gets exclusive all mouseEvents until you release the mouse. For example, you can press the mouse over a QSlider or QDial and leave the widget but you are still able to set the value of the slider or dial until you release the mouse again.

15th January 2006, 17:41
Yes. And there is no way around this?