[Qt-interest] QTextDocument and "\r\n" new-lines
Qt Quest
qt.quest at yahoo.com
Wed Mar 17 13:39:42 CET 2010
Anyone has an idea how to keep DOS/Windows text format - "\r\n" as new lines?
I'm using QPlainTextEdit. When loading a DOS file, the text document changes it to a 1-char newline text, so saving it to a file creates a UNIX text format.
Any workarounds?
Thanks!
--- On Thu, 3/11/10, Qt Quest <qt.quest at yahoo.com> wrote:
From: Qt Quest <qt.quest at yahoo.com>
Subject: QTextDocument and "\r\n" new-lines
To: qt-interest at trolltech.com
Date: Thursday, March 11, 2010, 7:28 AM
Hi all,
Currently, QTextDocument treats "\r\n" as "\n" when setting the document text.
The problem with this behavior is that the Qt would report the next line as starting one character earlier (and line 100: 100 characters earlier). This messes with the indexes which are computed with the file on the hard disk
Also, writing the file again will change the file format from dos to unix.
I tried changing QTextCursor::insertText line 1330:
if (ch == QLatin1Char('\r')
&& (i + 1) < text.length()
&& text.at(i + 1) == QLatin1Char('\n')) {
continue;
//++i;
//ch = text.at(i);
}
which solves the indexes problem, but now the visible-text-symbol-of-newline is shown (like in word processors). Any way to work around it?
Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100317/df34a74c/attachment.html
More information about the Qt-interest-old
mailing list