Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSettings->setValue , group contains space will save to %20 ?



  • If group contains space will save to %20, in Desktop Entry file of Linux will display mess code.

    writeSettings(filePath, "Desktop Entry", "Name", ui->lineEditName->text());
    
    void MainWindow::writeSettings(QString path, QString group, QString key, QString value)
    {
        QSettings *settings = new QSettings(path, QSettings::IniFormat);
        settings->setIniCodec("UTF-8");
        settings->beginGroup(group);
        settings->setValue(key, value);
        settings->endGroup();
    }
    

    [Desktop%20Entry]
    Name=KuWo
    ......



  • From http://doc.qt.io/qt-5/qsettings.html#Format-enum :

    The INI file format has severe restrictions on the syntax of a key. Qt works around this by using % as an escape character in keys.


Log in to reply