Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to input character CR(Carriage Return) in QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

How to input character CR(Carriage Return) in QTextEdit?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 8.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alvin.li
    wrote on last edited by
    #1

    As we all know, QTextEdit can be used to input characters.
    Characters input by user can be got by QTextEdit::toPlainText().
    My application needs user to input character CR(Carriage Return) into QTextEdit.
    Can character CR be input into QTextEdit?
    If it can, how to input it?
    And how to get it from QTextEdit?
    Does QTextEdit::toPlainText() work?

    By the way, my application can get character LF(Line Feed) from QTextEdit by QTextEdit::toPlainText() .
    CR can't be input into QTextEdit by pressing Ctrl+M .

    Thanks for any idea.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      According to "QTextEdit class documentation":http://qt-project.org/doc/qt-5.0/qtwidgets/qtextedit.html:

      bq. By default when reading plain text, one newline signifies a paragraph.

      And if you want to display a new line inside QTextEdit use the HTML tag for new line <br>

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alvin.li
        wrote on last edited by
        #3

        As a work around, replace("\n", "\r") can be used to make my function work.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved