[Qt-interest] howto convert QString to char*

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Wed Jul 14 09:58:02 CEST 2010


> Or perhaps:
>
> #define toChar(x) ((x).toLatin1().data())

Is this guaranteed to work? As in the QByteArray created here is only
temporary, so it ceases to exist after this statement?

I usually keep the QByteArray around as long as I need the "char *".
I've experienced some strange results while using this single line
(sometime I used to get garbage in the char pointer).

Regards,
-mandeep

>
> -gabriel
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list