Carriage return line feed - in qtextedit do not display text properly
I have a window with a qtextedit that I use for notes. 2 problems I am having. First is that the text being display from the db does not format to the carriage retrun and line feeds, it all appears as one lone string. I can display this same data in crystal report and the data is formatted correctly. 2nd issue is that when I update this text, it then appears to wipe out my carriage return line feeds. I am importing these note via mysql using a concat(note1, '\n', note2). Any idea's
Re: Carriage return line feed - in qtextedit do not display text properly
What if you concat \r\n instead of \n?
Re: Carriage return line feed - in qtextedit do not display text properly
I tried that with the same results.
Re: Carriage return line feed - in qtextedit do not display text properly
What is QTextEdit.lineWrapMode set to?
Re: Carriage return line feed - in qtextedit do not display text properly
Why are you performing the concatenation?
Re: Carriage return line feed - in qtextedit do not display text properly
It is set to Word wrap which work ok.
Re: Carriage return line feed - in qtextedit do not display text properly
Quote:
Originally Posted by
rdjenner
It is set to Word wrap which work ok.
Then I'm confused. This doesn't sound like a "one long string" problem anymore; it sounds more like you're expecting some sort of paragraph formatting - like a blank line insertion - following each CRLF.
If line wrapping is working, what exactly is the problem?
Re: Carriage return line feed - in qtextedit do not display text properly
I use concat because the old notes table had multiple lines for a order. Table structure was order, seq, note and for each new line of the note it would increase the seq. In other words I could have seq 1-15 with each note for that seq representing a new note line. When the notes print out, the need to display in that order. During the conversion I created a new table which was just order, note (varchar 4000) and when I import the old notes to the new I concat each seq of line notes with a \n to ensure the notes are displayed as seperate lines in my new text field. When I pull up these new notes in qtextedit, they appear as one long string, although when I pull these in crystal, they show up as new lines with the line feeds. When I edit the text in the qtextedit (add a new line) and redisplay it appears as one long string, although in crystal it appears correctly. If I go in and edit any portion of the text that was imported in, it appears to wipe out all line feeds because when I then pull up in crystal it appears as one huge string word wrap and ignores the previous line feeds.
Re: Carriage return line feed - in qtextedit do not display text properly
Fetch each paragraph separately and join them into one string in your application. Either that or repair the concatenated string you get from the database. Apparently your MySQL runs on Unix so \n is a LF instead of CRLF Windows expects. Using \r\n in your query should have worked too.
Re: Carriage return line feed - in qtextedit do not display text properly
See QTextDocument, QTextBlock and QTextBlockFormat. These allow you to control the display of your text, including adding margins above/below paragraphs.