Overriding general CustomWidget::mouseMoveEvent for a specific objects own mouseMoveEvent
-
This is a large complex app, so difficult to break down the code into small chunks for this audience.
We have a CustomWidget which is used to handle mouse/touch events for most other widgets.
We have one widget on which the users can either click a button and the button is activated, or they can click and move to move the whole widget.
On Windows systems this work fine, but testing on Android the button click is not registered and it always goes to the CustomWidget::mouseMoveEvent.
I think this might possibly be due to a higher touch sampling rate on Android than on Windows. We can if we deliberately try get the Windows app to behave similarly, but on Android we have to be very careful to click the button without moving/nudging the widget. If there is any hint as to what setting can be adjusted to control this that would be helpful.
widget1.cpp:
void widget1::mouseMoveEvent(QMouseEvent *e) { qDebug() << "Widget1 MouseMove"; CustomWidget::mouseMoveEvent(e); }
I added some qDebug to the
CustomWidget::mouseMoveEvent
method and it shows this gets called directly, bypassingwidget1::mouseMoveEvent
. Thiswidget1::mouseMoveEvent
only gets called if the widget is clicked and dragged some distance.How can I set
widget1::mouseMoveEvent
to be called for every mouseMoveEvent within widget1? -
Seems you need to enable mouse tracking for widget1, see:
void setMouseTracking(bool enable)
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.