一、QString str;
char *ch;
QByteArray ba = str.toLatin1();
ch = ba.data();
二、将QString转换为标准库string类型,然后将string转为char *
QString name;
std::string cstr = name.toStdString();
consr char *ch = str.c_str();
一、QString str;
char *ch;
QByteArray ba = str.toLatin1();
ch = ba.data();
二、将QString转换为标准库string类型,然后将string转为char *
QString name;
std::string cstr = name.toStdString();
consr char *ch = str.c_str();
转载于:https://www.cnblogs.com/jiangson/p/7596520.html