[Qt-interest] transforming QString into char *

Bob Hood bhood2 at comcast.net
Mon Mar 23 15:32:43 CET 2009


Giancarlo Amati wrote:
> Hello everybody,
>
> probably has been aswered already to this question...but I try:
>
> how can I transform a QString into a char * ?

There are several to*() methods for converting the internal contents of
the QString to something else.  Most return a QByteArray, which needs a
further cast.

I tend to use something like:

    const char *string_data = myString.toLatin1().constData();

Have a look:  http://doc.trolltech.com/4.5/qstring.html


-- 
Render me gone,                       |||
Bob                                 ^(===)^
---------------------------------oOO--(_)--OOo---------------------------------
      Imagine how hard it is to be intelligent in a world full of idiots.
                          Oh, nevermind.  You can't.




More information about the Qt-interest-old mailing list