diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-02-15 01:00:50 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-02-15 01:00:51 +0100 |
commit | ef2ddcf551dec13215cb45cb000731f94b2f8e34 (patch) | |
tree | c8810f6ee77a81c3003ccc8783c9d3b17f0b8a5e /src/widgets/widgets/qcalendarwidget.cpp | |
parent | e2cf6ade3535467bc2f21b54b82ed007d5ce279b (diff) | |
parent | 501cca2c4b0851cea7133ba56c3a05d71c25ce6d (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I8cad26f17834dbc9f7151edc0f17786f9e32025d
Diffstat (limited to 'src/widgets/widgets/qcalendarwidget.cpp')
-rw-r--r-- | src/widgets/widgets/qcalendarwidget.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 7637877926..47c5267c73 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -3064,19 +3064,22 @@ bool QCalendarWidget::eventFilter(QObject *watched, QEvent *event) { Q_D(QCalendarWidget); if (event->type() == QEvent::MouseButtonPress && d->yearEdit->hasFocus()) { + // We can get filtered press events that were intended for Qt Virtual Keyboard's + // input panel (QQuickView), so we have to make sure that the window is indeed a QWidget - no static_cast. + // In addition, as we have a event filter on the whole application we first make sure that the top level widget + // of both this and the watched widget are the same to decide if we should finish the year edition. QWidget *tlw = window(); - QWidget *widget = static_cast<QWidget*>(watched); - //as we have a event filter on the whole application we first make sure that the top level widget - //of both this and the watched widget are the same to decide if we should finish the year edition. - if (widget->window() == tlw) { - QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos()); - QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size()); - if (!geom.contains(mousePos)) { - event->accept(); - d->_q_yearEditingFinished(); - setFocus(); - return true; - } + QWidget *widget = qobject_cast<QWidget *>(watched); + if (!widget || widget->window() != tlw) + return QWidget::eventFilter(watched, event); + + QPoint mousePos = widget->mapTo(tlw, static_cast<QMouseEvent *>(event)->pos()); + QRect geom = QRect(d->yearEdit->mapTo(tlw, QPoint(0, 0)), d->yearEdit->size()); + if (!geom.contains(mousePos)) { + event->accept(); + d->_q_yearEditingFinished(); + setFocus(); + return true; } } return QWidget::eventFilter(watched, event); |