我测试了三种方法,方法一是成功的。大家可以都试一下,总有可以解决的。
1.QStringLiteral
直接在中文前面加这句话就好了,下面有我的乱码样式,还有成功改过来的样式。
textLabel = new QLabel(QStringLiteral("选择模型"));
2.tr()
这总方法一样,直接加,我测试我的代码,没有成功。
textLabel = new QLabel(tr("选择模型"));
3.加一行编码
我测试也不行。
#include <QTextCodec>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
// 你的代码
}