1.QString -> char*
#include<QTextCodec>
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QString str="中国人民"; char* ch; // QByteArray ba = str.toLatin1(); QByteArray ba = str.toLocal8Bit(); ch=ba.data(); qDebug()<<ch;
2. char*-> QString
QString str; char *msg; str = QString::fromLocal8Bit(msg);
时间: 2024-11-14 14:34:25