PDA

View Full Version : conversion from QString to const uint8 *



vishal.chauhan
19th February 2007, 10:15
Hi All,

I m using Qt 4.2.2 on my Intel Mac.
I want to convert QString to const uint8 *.

In Qt3 I m using
(const UInt8*)cCompletePath.utf8()

to convert this.

But how to do this in Qt 4.2.2 ?

I m using

(const UInt8*)cCompletePath.utf16()

to Do this but this is converting into 16 bit unicode but I need it in 8 bit unicode.


If anyone knows then plz help me.

Thanks.

camel
19th February 2007, 12:33
Take a look at the wonderfull documentation (http://doc.trolltech.com/4.2/qstring.html#toUtf8).

Coding is left as an exercise for the reader ;-)

vishal.chauhan
19th February 2007, 13:05
Thanks for reply.

I have tried convert the QString to the unicode using toUft8
but the value return by this is a ByteArray and how I convert this value into (const UInt8*).

wysota
19th February 2007, 13:14
Use the constData() method from QByteArray. Just remember to copy the buffer if you want to store it anywhere as the pointer will be valid only as long as the byte array object is valid.