How to convert QString to LPCSTR (Unicode)

user666491 picture user666491 · Mar 26, 2011 · Viewed 13.5k times · Source

how can I convert QString to LPCSTR ?

How do I do it when #ifdef UNICODE is defined and when it isn't ?

Thanks very much :)

Answer

snoofkin picture snoofkin · Mar 26, 2011

I guess:

QString str("ddddd");
LPCSTR lstr = str.toStdString().c_str();