Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    2
    1281
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sonichy
      sonichy last edited by

      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
      ......

      https://github.com/sonichy

      1 Reply Last reply Reply Quote 0
      • VRonin
        VRonin last edited by VRonin

        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.

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 6
        • First post
          Last post