Results 1 to 10 of 10

Thread: Carriage return line feed - in qtextedit do not display text properly

  1. #1
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    What if you concat \r\n instead of \n?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    I tried that with the same results.

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    What is QTextEdit.lineWrapMode set to?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    Why are you performing the concatenation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    It is set to Word wrap which work ok.

  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Carriage return line feed - in qtextedit do not display text properly

    Quote Originally Posted by rdjenner View Post
    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?

  8. #8
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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.

Similar Threads

  1. Carriage Return in QString
    By incapacitant in forum Newbie
    Replies: 7
    Last Post: 2nd December 2010, 09:18
  2. Having trouble with carriage return
    By FoleyX90 in forum Newbie
    Replies: 0
    Last Post: 27th May 2010, 16:15
  3. Replies: 0
    Last Post: 9th August 2009, 22:59
  4. removing carriage return from QString
    By gren15 in forum Qt Programming
    Replies: 3
    Last Post: 28th June 2009, 22:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.