Fix QTextEdit/QPlanTextEdit palette not updated on ActivationChange

When a QTextEdit/QPlanTextEdit window loses focus and receives
PaletteChange event, the ColorGroup that controls the palette for
the QWidgetTextControl will be set to 'Inactive'. However, the
QTextEdit does not update the palette when the window is activated again.
This can become more noticeable in applications where different colors
are used for the 'Inactive' and 'Active' ColorGroups.

Pick-to: 6.5 6.6
Change-Id: Idd4dcc55b2bf8e671e7dd9cbd040782e1c3bf1a3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Mike Chen 2023-06-08 14:19:52 +08:00
parent 02ca59c4c8
commit 4afcdc488f
2 changed files with 2 additions and 0 deletions

View File

@ -2301,6 +2301,7 @@ void QPlainTextEdit::changeEvent(QEvent *e)
d->control->document()->setDefaultFont(font());
break;
case QEvent::ActivationChange:
d->control->setPalette(palette());
if (!isActiveWindow())
d->autoScrollTimer.stop();
break;

View File

@ -1897,6 +1897,7 @@ void QTextEdit::changeEvent(QEvent *e)
|| e->type() == QEvent::FontChange) {
d->control->document()->setDefaultFont(font());
} else if (e->type() == QEvent::ActivationChange) {
d->control->setPalette(palette());
if (!isActiveWindow())
d->autoScrollTimer.stop();
} else if (e->type() == QEvent::EnabledChange) {