
Originally Posted by
barrygp
const char * asdfasdf = s.toAscii().data();
Left: const char *
Right: char *
const char * asdfasdf = str.c_str();
Left: const char *
Right: const char *
See the difference?
const char *xyz = s.toAscii().constData();
QString s;
const char *xyz = s.toAscii().constData();
To copy to clipboard, switch view to plain text mode
By the way, all these assignments can lead to a crash.
You can try this:
const char *xyz = ba.constData(); // as long as ba exists, xyz will be valid
QString s;
QByteArray ba = s.toAscii();
const char *xyz = ba.constData(); // as long as ba exists, xyz will be valid
To copy to clipboard, switch view to plain text mode
Bookmarks