[Qt-interest] howto convert QString to char*

Matthias Pospiech matthias.pospiech at gmx.de
Tue Jul 13 17:58:19 CEST 2010


Matthias Pospiech schrieb:
> I am using the following:
>
>     char * toChar(const QString str)
>     {
>         QByteArray ba = str.toLatin1();
>         return  ba.data();
>     }
>
> the bytearray contains usefull data,
> however the value returned by data() is very useless.
>   
Just as an example:
The original String "1.000" is converted to
0x957c944 
"\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\356\376\a"

Matthias




More information about the Qt-interest-old mailing list