textBrowser->setSource() end-of-line
I'm using QTextBrowser with setSource() to display the contents of a text file. The problem is that EOL in the text file is ignored (actually treated as a space). I've tried setting EOL in the file to both DOS and Unix versions, but it makes no difference. How can I get QTestBrowser to apply a CR at the end of the text lines?
Thanks
Gib
Re: textBrowser->setSource() end-of-line
Quote:
I've tried setting EOL in the file to both DOS and Unix versions, but it makes no difference.
can you show your code?
Re: textBrowser->setSource() end-of-line
Quote:
Originally Posted by
high_flyer
can you show your code?
There isn't much to show:
QString infoFile = "info.txt";
ui->textBrowser->setSource(infoFile);
info.txt is a text file with multiple lines. In the QTextBrowser widget the lines are all concatenated, with spaces in place of the CR-LF.
Re: textBrowser->setSource() end-of-line
but you said:
Quote:
I've tried setting EOL in the file to both DOS and Unix versions,
So how/where did you try to set EOL?
Re: textBrowser->setSource() end-of-line
Quote:
Originally Posted by
high_flyer
but you said:
So how/where did you try to set EOL?
In my text editor (where I created info.txt) I have the option of setting end-of-line to DOS format (CR-LF) or Unix format (LF). I've tried saving the file with each format, and in both cases QTextBrowser just concatenates all the lines in the display.
Added after 1 56 minutes:
Quote:
Originally Posted by
high_flyer
but you said:
So how/where did you try to set EOL?
I have now tried converting my text file to rich text (by saving it as .rtf in Word Pad). Now EOL is displayed as \par, with the same concatenation. At the head of the displayed text I see what is presumably the formating info for the rich text:
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}} {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\lang1033\f0\fs22
I'm wondering if QTextBrowser was designed just for html, but the docs say:
"The QTextBrowser class provides a rich text browser with hypertext navigation."
Re: textBrowser->setSource() end-of-line
what happens if you open your original file with a simple text editor line notepad or wordpad?
Re: textBrowser->setSource() end-of-line
Quote:
Originally Posted by
high_flyer
what happens if you open your original file with a simple text editor line notepad or wordpad?
Sorry, I don't understand the question. As I said, I created the original file with a simple text editor, and then an RTF version with Wordpad. There's nothing special about these files. I've tested with other text files, and the result is always the same - loss of formatting when displayed in QTextBrowser. I'm using Qt 4.7.0, BTW.
Re: textBrowser->setSource() end-of-line
Did you try with QTextEdit?
Re: textBrowser->setSource() end-of-line
Quote:
Originally Posted by
high_flyer
QTextEdit does not have a member SetSource(). I chose to use QTextBrowser because I wanted to use SetSource(). I'm aware that I could achieve what I want by reading from the text file and writing to a QTextEdit widget. My query concerns getting EOLs recognized in QTextBrowser. Is the observed behaviour (replacement of EOL by space) also intended (i.e. is it a bug or a feature)?