[Qt-interest] Newline character in QLineEdit

Atlant Schmidt aschmidt at dekaresearch.com
Wed Apr 6 14:15:33 CEST 2011


Robert:

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

  That's not exactly true. We can all think of examples of user-level
  applications that also take these "escape" characters although, as
  I hinted in my previous reply, there's no standardized format. For
  example, the Microsoft Office tools let you use a variety of these
  sequences to search for all sorts of Wordish metacharacters (such
  as ^n for newline and ^p for a paragraph marker:

    http://support.microsoft.com/kb/95474


  BBEdit on the Macintosh exposes grep, so it uses \n to represent
  a newline:

    http://www.anybrowser.org/bbedit/grep.shtml


  That might be why Surya was thinking along these lines; there's
  lots of precedent to expose these sequences to ordinary users.

                               Atlant

________________________________
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Robert Escott
Sent: Wednesday, April 06, 2011 07:33
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Newline character in QLineEdit

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


Click here<https://www.mailcontrol.com/sr/Y0IZ+hdkb9nTndxI!oX7Us7Qlo!t9IHtWzvek7houGO7BDwhtDirgotzASGAOpQPZ1fjyImhkJXZM0Vr2cPI!w==> to report this email as spam.

________________________________
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110406/77eebb2d/attachment.html 


More information about the Qt-interest-old mailing list