View Full Version : QTextEdit not display new line characters

30th November 2011, 03:48
So I have this little chat program. Problem lies when display messages onto the output box. The output box is a QTextEdit and so is the input. In order to place messages sent and received onto output box I use the append function.. but if I send text with new line characters the new line character's dont appear and all the the text appears in a single line. if I qDebug() the string I am going to append right before appending I see the correct text format.

Example error

Cat race

I will get in the output box Dog cat race

Any help is great

30th November 2011, 04:49
QTextEdit understands a HTML subset and newlines in HTML text are generally treated as a space. Replace occurrences of '\n' in your text with "<br/>", or wrap lines in your text with <p></p> to make a paragraph of it.

If you only want plain text then you could use QPlainTextEdit.

30th November 2011, 05:46
Thanks for the suggestion but I fixed it myself