[Qt-interest] howto convert QString to char*

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Jul 14 13:45:02 CEST 2010


> QString my="Hello World";
> char*cs=toChar(my);

The QByteArray is gone after this line! :)

> printf("%s\n",cs);
>
> I hope you can spot the difference!

Using QByteArray::data() each time one wants to use "char *", seems to
be the safest bet.

Thanks,
-mandeep



More information about the Qt-interest-old mailing list