View Full Version : QTextBrowser NewLine

17th January 2009, 05:34
I have a standard .txt file I am trying to display in a QTextBrowser widget. I create the (file.txt) from standard IO stream.
If I view the (file.txt) in my editor it is properly formatted. However when I display the QTextBrowser widget the text is not formatted to the end of each line. Seems like it doesn't recognize the 'endl' -- new line in my text document.
The text is wrapped until the end of the widget. I tried nowrapping but it doesn't work.
for example (text.file):
I want this.
Item#1: Test item
Item#2: Test 2 Item
Item#3: Test 3 Item

QTextBrowser displays this as
Item#1: Test Item Item#2: Test 2 Item Item#3 Test 3 Item..(until end of widget)


EDIT*** My bad, fixed the problem
inserted <pre> "my text" </pre>, at the beginning and end of the file.

17th January 2009, 08:34
If you only want to display a pure text document without HTML, better use QPlainTextEdit with is editable set to false. It is much more efficient for your needs.