Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.2, 5.12.4
-
None
Description
According to Qt event system, mouse double-clicking turn into the following sequence of events:
(1)QEvent::MouseButtonPress -> (2)QEvent::MouseButtonRelease -> (3)QEvent::MouseButtonPress -> (4)QEvent::MouseButtonDblClick -> (5)QEvent::MouseButtonRelease (See link title for details).
For QtWidgets subsystem (3) event generates after (4):
// QWidget.cpp
void QWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
mousePressEvent(event);
}
Thus, reimplementation of QQuickwidget::mouseDoubleClickEvent send additional QEvent::MouseButtonPress event to QtQuick subsystem using the above order, BUT flags of this event not marked as Qt::MouseEventCreatedDoubleClick ---> at QtQuick Scene Graph side it is impossible to determine whether the (3) event is related to mouse double-clicking.
To solve the problem it is necessary to mark event in the following way:
// Sample widget derived from QQuickWidget void QuickWidget::mouseDoubleClickEvent(QMouseEvent *e) { QMouseEvent pressEvent(QEvent::MouseButtonPress, e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); // ---> QGuiApplicationPrivate::setMouseEventFlags(&pressEvent, pressEvent.flags() | Qt::MouseEventCreatedDoubleClick); // Bug FIXER!!! // ---> QGuiApplication::sendEvent(quickWindow(), &pressEvent); e->setAccepted(pressEvent.isAccepted()); QMouseEvent mappedEvent(e->type(), e->localPos(), e->localPos(), e->screenPos(), e->button(), e->buttons(), e->modifiers(), e->source()); QGuiApplication::sendEvent(quickWindow(), &mappedEvent); }
Sample is attached in the archive