QWidgetTextControl: emit cursorPositionChanged() when select all

Fixes: QTBUG-91643
Pick-to: 6.5
Change-Id: I31745a3106321da0be4074a33768da8b84a8ae3f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Liang Qi 2023-04-20 10:29:12 +02:00
parent 034a071bda
commit fed79b873e
2 changed files with 8 additions and 0 deletions

View File

@ -967,9 +967,12 @@ void QWidgetTextControl::selectAll()
{
Q_D(QWidgetTextControl);
const int selectionLength = qAbs(d->cursor.position() - d->cursor.anchor());
const int oldCursorPos = d->cursor.position();
d->cursor.select(QTextCursor::Document);
d->selectionChanged(selectionLength != qAbs(d->cursor.position() - d->cursor.anchor()));
d->cursorIsFocusIndicator = false;
if (d->cursor.position() != oldCursorPos)
emit cursorPositionChanged();
emit updateRequest();
}

View File

@ -757,6 +757,11 @@ void tst_QTextEdit::cursorPositionChanged()
QCOMPARE(spy2.cursorPositions.size(), 1);
QCOMPARE(spy2.cursorPositions.at(0), 0);
QCOMPARE(ed->textCursor().position(), 0);
ed->selectAll();
QCOMPARE(spy2.cursorPositions.size(), 2);
QCOMPARE(spy2.cursorPositions.at(1), 11);
QCOMPARE(ed->textCursor().position(), 11);
}
void tst_QTextEdit::setTextCursor()