Results 1 to 3 of 3

Thread: QTextEdit not display new line characters

  1. #1
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextEdit not display new line characters

    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

    Dog
    Cat race

    I will get in the output box Dog cat race

    Any help is great
    Last edited by aruval3; 30th November 2011 at 03:00.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTextEdit not display new line characters

    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.

  3. #3
    Join Date
    Nov 2011
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTextEdit not display new line characters

    Thanks for the suggestion but I fixed it myself

Similar Threads

  1. QString argument ignoring new line characters
    By qtnewbi3 in forum Qt Programming
    Replies: 4
    Last Post: 15th August 2011, 22:18
  2. Replies: 9
    Last Post: 28th March 2011, 22:51
  3. QTextEdit and Chinese characters on a Mac
    By jupi32000 in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2010, 01:02
  4. read an xml file with Asian characters in QTextEdit
    By Boris Liao in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2010, 22:56
  5. Problem with korean characters display
    By giriprasad in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th September 2009, 08:40

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.