I have a QString that I need to pass as qrgument to a C dll wanting a char*.
When I do like this:
char* str_p = myQString.toAscii().constData();
qDebug("%s", str_p );
It prints ???????? all over the screen so the pointer is crap.
However if I do like this:
QByteArray ba = myQString.toAscii();
char* str_p = ba.constData();
qDebug("%s", str_p);
It works just fine.
I really would like to have the QString to char* conversion as a one liner, why does the first approach fail?
Bookmarks