From 17eb0f2d8a84eb54e6e4fbfa981ca3bae8c7e919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Wed, 5 Jan 2022 08:44:50 +0100 Subject: [PATCH] Keep original text for text/plain mime data For historical reasons, QTextDocument[Fragment]::toPlainText replaces nbsp character (U+00A0) with a normal space, and U+2029, and U+2028 characters with a line feed character. This behavior differs from native (plain) text editors. It also creates an asymetry, because the characters in question can be pasted into the document, but not copied out of it. Use the newly introduced QTextDocumentFragment::toRawText() to avoid this conversion. [ChangeLog][QtGui][Drag&Drop] Special characters like   are now preserved in the text/plain part of the clipboard when copied from a QTextEdit or QLineEdit. Fixes: QTBUG-99572 Change-Id: If01a5dd98127a59be15a425dc029c7303bce18f1 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/widgets/qwidgettextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 8c849ddbae3..ef1158b8ceb 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -3498,7 +3498,7 @@ void QTextEditMimeData::setup() const that->setData(QLatin1String("application/vnd.oasis.opendocument.text"), buffer.data()); } #endif - that->setText(fragment.toPlainText()); + that->setText(fragment.toRawText()); fragment = QTextDocumentFragment(); }