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.