diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-10-14 15:54:13 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2016-10-17 07:29:10 +0000 |
commit | ae6681673eb5c7768070cad61f483d2a5405dc9e (patch) | |
tree | 60b47153bc84d8b1f1a61e6667c176a261a1ba61 /src/gui/text/qtextdocument.cpp | |
parent | 9944a12a0f57087ea19ae428ffcd974ac0fed7bc (diff) | |
download | qtbase-ae6681673eb5c7768070cad61f483d2a5405dc9e.tar.gz |
Add QTextDocument::toRawText() function
The QTextDocument::toPlainText() converts some characters in the
text to ASCII, which can be problematic for use cases where you
want to save the precise contents of the document, e.g. in
Qt Creator. Since we don't want to change the behavior of
toPlainText(), we introduce a new function which returns the
raw text contents of the document instead, with no modifications.
[ChangeLog][QtGui][Text] Added QTextDocument::toRawText() function.
Task-number: QTBUG-56538
Change-Id: Ib6c48a16551c4c71c4c431760f993793d1af6806
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/text/qtextdocument.cpp')
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 07aec6f019..61bab2dbfd 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1145,9 +1145,28 @@ void QTextDocument::setMetaInformation(MetaInformation info, const QString &stri } /*! + Returns the raw text contained in the document without any + formatting information. If you want formatting information + use a QTextCursor instead. + + \since 5.9 + \sa toPlainText() +*/ +QString QTextDocument::toRawText() const +{ + Q_D(const QTextDocument); + return d->plainText(); +} + +/*! Returns the plain text contained in the document. If you want formatting information use a QTextCursor instead. + This function returns the same as toRawText(), but will replace + some unicode characters, such as line separators and non-breaking + spaces, with ASCII alternatives. If you need the precise contents + of the document, use toRawText() instead. + \note Embedded objects, such as images, are represented by a Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER). |