QT solves QSettings reading ini file Chinese garbled

I used to read the ini file Chinese garbled online search method and use custom QSettings, but errors may occur when reading and writing frequently; later, I made a special tool for users to modify the configuration.

I accidentally saw the method posted by netizens on the Internet. The method is very simple:

QSettings settings("xxx.ini", QSettings::IniFormat);
settings.setIniCodec("GB2312");
settings.beginGroup("xx");
...
settings.endGroup();

Note that the encoding must be set after the QSettings object is created and before accessing the data, this function was introduced in Qt 4.5.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324432802&siteId=291194637