qt-interest@trolltech.com
[Top] [All Lists]

Re: setText "\n" on a button doesn't work

Subject: Re: setText "\n" on a button doesn't work
From: Kuba Ober
Date: Thu, 10 Mar 2005 13:00:21 -0500
On Åroda 09 marzec 2005 05:15 pm, Song Yun Zhao wrote:
> Dimitri wrote:
> > What are the contents of the XML file and how do you read it? If the XML
>
> The XML file looks something like this:
>
>          <Input1>
>              <Value>24VI\nSensing</Value>
>              <Type>string</Type>
>          </Input1>
>
>
> I'm reading the XML file with a class which opens it with QFile and
> QDomDocument. There is class method that looks something like this:
> getValue(tag, label), where tag and label are both QStrings.
>
> > file contains the two characters "\n" you would have to first translate
> > them to the single newline character.
>
> As can be seen above it only contains \n (without the double quotation
> marks). What do you mean by translating it?

I guess you didn't know that C/C++ converts escapes in strings to actual 
control characters.

The `\n` in your text file is just two characters with zero termination: 
{ '\', 'n', 0 }. What you're looking for is the actual newline, which in 
C/C++ you can write as "\n" (a string) or '\n' (a character). Do a simple 
string replace on your label, replacing "\\n" { '\', 'n', 0 } with 
"\n" { '\n', 0 }

Cheers, Kuba Ober

--
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>