Results 1 to 4 of 4

Thread: insertPlainText and carriage return

  1. #1
    Join Date
    Oct 2010
    Location
    Porto Alegre
    Posts
    19
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default insertPlainText and carriage return

    term is a class that descends from QPlainTextEdit.

    This is my code:
    Qt Code:
    1. QByteArray ba = "Test123\r";
    2. term->insertPlainText(ba);
    3. term->insertPlainText("ABC");
    To copy to clipboard, switch view to plain text mode 

    I was expecting that the result of this code was like this:
    Qt Code:
    1. ABCTest123
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. ABCt123
    To copy to clipboard, switch view to plain text mode 
    ABC should be in the same line that Teste123 was.
    But the result is
    Qt Code:
    1. Test123
    2. ABC
    To copy to clipboard, switch view to plain text mode 

    Just want the carriage return to return the carriage in the same line.
    Is it possible or do I have to treat this kind of thing manually?

    Thanks is advance

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: insertPlainText and carriage return

    You have to remove \r before inserting.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2010
    Location
    Porto Alegre
    Posts
    19
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: insertPlainText and carriage return

    So, if I want to treat this behavior, I have to do it manually?

    Thanks

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: insertPlainText and carriage return

    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. The following user says thank you to spirit for this useful post:

    RenanBS (29th August 2012)

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.