QQuickWidget: fix drag and drop
QQuickWidget did not receive mouse release events after drag and drop because the logic was so: 1) QWidgetWindow::handleMouseEvent() was called on press and qt_button_down was set to the corresponding QQuickWidget; 2) After drag started, qt_button_down was set to 0 in QApplicationPrivate::notifyDragStarted(); 3) On mouse release QWidgetWindow::handleMouseEvent() was called again, but because qt_button_down was 0 QApplicationPrivate::pickMouseReceiver() returned 0 and as a result QWidgetWindow ignored the event and did not propagate it to QQuickWidget for further processing. The step 2 is a widgets-specific fix for QTBUG-26145 that does not work for QQuickWidget (QtQuick has its own focus system). Note that because Widgets and QtQuick do not share the sources, there is no possibility to cast the pointer to check whether qt_button_down is a QQuickWidget or some other QWidget-derived class object, so we have to use QObject::inherits() method to check that. Task-number: QTBUG-56713 Change-Id: I599b843e903c64329e6178752e0dc49f674bb890 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
5060740fa9
commit
a41677d04c
@ -4501,9 +4501,13 @@ void QApplicationPrivate::notifyThemeChanged()
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
void QApplicationPrivate::notifyDragStarted(const QDrag *drag)
|
||||
{
|
||||
// Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation.
|
||||
QGuiApplicationPrivate::notifyDragStarted(drag);
|
||||
qt_button_down = 0;
|
||||
// QTBUG-26145
|
||||
// Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation...
|
||||
// QTBUG-56713
|
||||
// ...only if qt_button_down is not a QQuickWidget
|
||||
if (qt_button_down && !qt_button_down->inherits("QQuickWidget"))
|
||||
qt_button_down = nullptr;
|
||||
}
|
||||
#endif // QT_NO_DRAGANDDROP
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user