试了改编码等方式,发现最直接的方式还是加QStringLiteral
举个例子,下面那句是我ui界面有一个命名为connectpushbutton的pushbutton,在settext里面增加了QStringLiteral
ui->connectpushButton->setText(QStringLiteral("断开"));
由于这篇篇幅实在太少,我就把qt对于这个函数的定义也复制上来吧
The macro generates the data for a QString out of str at compile time if the compiler supports it. Creating a QString from it is free in this case, and the generated string data is stored in the read-only segment of the compiled object file.
For compilers not supporting the creation of compile time strings, QStringLiteral will fall back to QString::fromUtf8().
反正是很可靠的解决了乱码的问题