[Qt-interest] QTextEdit: insertPlainText at the end of the "text" keeping current output font style
Torsten Krah
tkrah at fachschaft.imn.htwk-leipzig.de
Wed Feb 25 07:35:28 CET 2009
Hi.
I am going to output telnet data (text) in a QTextEdit view.
I am not using append because the text is using ansi style colors and i am
going to parse them and change the font on my QTextEdit view while processing
the telnet input and writing the text to the view whenever needed (new color
or something else).
This works fine so far, however if the user scrolls and the current cursor is
not at the end and input is received from the telnet stream its not written at
the correct destination (End).
I tried to use this:
QTextCursor c = ui.output->textCursor();
c.movePosition(QTextCursor::End);
ui.output->setTextCursor(c);
ui.output->ensureCursorVisible();
ui.output->insertPlainText(text);
which solves my problem that the text is not inserted at the end of the
output.
But my styles are lost - all settings done to the view like:
setTextBackgroundColor or setTextColor
while parsing my raw input is lost.
Without this cursor stuff above color & co are there.
So why are these settings lost and how can i have both, keeping my settings on
the output view and scroll the cursor to the end and insert text there?
thx for help.
Torsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1996 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090225/36c8d922/attachment.bin
More information about the Qt-interest-old
mailing list