Bug or feature: Hover-highlighting isn't reset if a QDialog is shown by a widget being hover-highlighted
-
Hi :-)
This is probably some speacial case, so I'm not sure if what I see is only unexpected behavior or a bug.
I use a
QRadioButton
derived class which catches right mouse clicks. When being clicked by the right mouse button, the radio button is selected as if it was clicked by the left button, but additinally, aQDialog
derived dialog is shown. I achieve this with the following code (stripped down to the relevant parts) inside my QRadioButton class:void BoogerRadioButton::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::RightButton) { if (! isChecked()) { setChecked(true); emit clicked(); } emit scoreDialogRequested(); } else { QRadioButton::mousePressEvent(event); } }
The
scoreDialogRequested
signal triggers the dialog to be shown. The result is that the highlighting set by the mouse cursor hovering the radio button stays until the cursor re-enters the button and leaves it again. Here's a screenshot:As a workaround, I call
QWidget::mouseMoveEvent
with aQMouseEvent
taking part one pixel outside of the widget after emitting the signal triggering the dialog to show up, which makes the highlighting go away. Like this:QMouseEvent ev(QEvent::MouseMove, QPointF(-1.0, -1.0), Qt::NoButton, Qt::NoButton, Qt::NoModifier); mouseMoveEvent(&ev);
So … is this a bug or a feature?! ;-)
-
Usely, the button is selected on mouse release and only if the mouse cursor is still inside the button.
On mouse press, the button is only highlighted.
You go against standard behavior and so the issue you describe