QT5中含中文的QByteArray与QString互转
QString strcn = "C Primer Plus 人民邮电出版社";
qDebug() << "strcn = "<<strcn;
QByteArray bytes = strcn.toLocal8Bit();
qDebug() << "bytes = "<<bytes;
QTextCodec *tc = QTextCodec::codecForName("GBK");
QString tmp = tc->toUnicode(bytes);
qDebug() << "tmp = "<<tmp;
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f79c00a1cd5769858374eeb20ca17d72.png)