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



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



  • 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>



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.