InputMethod should call reset() function when proxywidget lost focus

fix When the preview of input Chinese appears,the proxyWidget
lose focus and does not call the reset method of inputMethod.

Fixes: QTBUG-88016
Pick-to: 5.15
Change-Id: I82a66207b0d2046d768430ac3e93df86c1ed3681
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Zhang Hao 2020-10-29 15:24:26 +08:00
parent 68f3e37449
commit bf5011815d
1 changed files with 12 additions and 1 deletions

View File

@ -1391,6 +1391,11 @@ void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
break;
}
// QTBUG-88016
if (d->widget && d->widget->focusWidget()
&& d->widget->focusWidget()->testAttribute(Qt::WA_InputMethodEnabled))
QApplication::inputMethod()->reset();
d->proxyIsGivingFocus = false;
}
@ -1406,8 +1411,14 @@ void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event)
if (d->widget) {
// We need to explicitly remove subfocus from the embedded widget's
// focus widget.
if (QWidget *focusWidget = d->widget->focusWidget())
if (QWidget *focusWidget = d->widget->focusWidget()) {
// QTBUG-88016 proxyWidget set QTextEdit(QLineEdit etc.) when input preview text,
// inputMethod should be reset when proxyWidget lost focus
if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
QApplication::inputMethod()->reset();
d->removeSubFocusHelper(focusWidget, event->reason());
}
}
}