[Qt-interest] Newline character in QLineEdit

Robert Escott robert at binarylogic.co.za
Wed Apr 6 13:32:57 CEST 2011


Hi Surya

 

The \n escape sequence is only understood by the compiler and is converted to the newline character when you compile your source. 

 

If you want your program to understand that the character sequence entered by users as the newline character then you need to program this in yourself. The easiest way is to user the replace function of QString.

 

Eg. QString userText = lineEdit->text().replace(“\\n”, ‘\n’).replace(“\\t”, ‘\t’);

 

I can’t think of why you’d actually want to do this. The QTextEdit or QPlainTextEdit widgets make more sense if you want multi-lined input.

 

From: qt-interest-bounces+robert=binarylogic.co.za at qt.nokia.com [mailto:qt-interest-bounces+robert=binarylogic.co.za at qt.nokia.com] On Behalf Of Surya Kiran Gullapalli
Sent: 06 April 2011 08:08
To: qt-interest List
Subject: [Qt-interest] Newline character in QLineEdit

 

Hello all,
I'm trying to get user input in QLineEdit, User may type in newline character as \n, but QLineEdit is returning the \n as a QString of 2 characters instead of one. 

How to force QLineEdit to correctly return characters like \n, \t etc.

Thanks,
Surya

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110406/df78a5da/attachment.html 


More information about the Qt-interest-old mailing list