Reputation: 79
I am trying to convert QString into char*. The code that i have been using is
QString username = useradd->text();
QByteArray un=username.toLatin1();
const char *str = un.data();
Where useradd
is the name given to "lineedit"
On compilation the following error occurs
class
QString
has no member namedtoLatin1
Upvotes: 0
Views: 1236
Reputation: 19152
If you are using only once, like in a debug line, use this:
http://qt-project.org/doc/qt-4.8/qtglobal.html#qPrintable
This is equivalent to str.toLocal8Bit().constData().
qDebug() << qPrintable(myString);
Upvotes: 0