Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QSettings problem with .desktop file

QSettings problem with .desktop file

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 2 Posters 6.1k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    b0unc3
    wrote on last edited by
    #1

    Hello,

    I'm trying to edit a .desktop file on MeeGo using QSettings and when I modified an entry (in a group) then the group, that is [Desktop Entry] becomes [Desktop Entry].
    What I can do to have it wrote correctly without the ?
    Thanks.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      [quote author="b0unc3" date="1330002682"]Hello,

      I'm trying to edit a .desktop file on MeeGo using QSettings and when I modified an entry (in a group) then the group, that is [Desktop Entry] becomes [Desktop Entry].
      What I can do to have it wrote correctly without the ?
      Thanks.[/quote]

      [Desktop Entry] becomes [Desktop Entry] What do you mean? Please give more details and your source code.

      http://anavi.org/

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b0unc3
        wrote on last edited by
        #3

        Oh sorry, I didn't notice that the character was substituted in the thread text.
        I mean that the whitespace in [Desktop Entry] becomes [Desktop% 20Entry].

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leon.anavi
          wrote on last edited by
          #4

          [quote author="b0unc3" date="1330011772"]Oh sorry, I didn't notice that the character was substituted in the thread text.
          I mean that the whitespace in [Desktop Entry] becomes [Desktop% 20Entry].
          [/quote]

          Hm... the space has been replaced with just like as it is using URL encoding. It is strange what is causing it. It would be nice if you post the source code that you are using to process the config file. But anyway as a work around you can use "QUrl":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html to detect encoded url characters and decode them.

          http://anavi.org/

          1 Reply Last reply
          0
          • B Offline
            B Offline
            b0unc3
            wrote on last edited by
            #5

            [quote author="leon.anavi" date="1330012229"]
            Hm... the space has been replaced with just like as it is using URL encoding. It is strange what is causing it. It would be nice if you post the source code that you are using to process the config file. But anyway as a work around you can use "QUrl":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html to detect encoded url characters and decode them.
            [/quote]

            Yes exactly.
            A base code like this, will give you this behavior:
            @
            QSettings settings("file.desktop", QSettings::IniFormat);
            settings.beginGroup("Desktop Entry");
            settings.setValue("Name", "test");
            settings.endGroup();
            settings.sync();
            @

            I don't know if I can use QUrl as a workaround, I don't see how.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leon.anavi
              wrote on last edited by
              #6

              OK... so it appears that in the original definition of INI files used at Microsoft Windows sections and key names should not contain any spaces. Therefore QSettings automatically replaces the spaces with % 20.

              A macros "QT_NO_URL_CAST_FROM_STRING":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html#QT_NO_URL_CAST_FROM_STRING is described at Qt documentation for QSettings Try to fix your issue using it. According to this description it will disables automatic conversions from QString (or char *) to QUrl.

              http://anavi.org/

              1 Reply Last reply
              0
              • B Offline
                B Offline
                b0unc3
                wrote on last edited by
                #7

                [quote author="leon.anavi" date="1330015036"]OK... so it appears that in the original definition of INI files used at Microsoft Windows sections and key names should not contain any spaces. Therefore QSettings automatically replaces the spaces with % 20.

                A macros "QT_NO_URL_CAST_FROM_STRING":http://developer.qt.nokia.com/doc/qt-4.8/qurl.html#QT_NO_URL_CAST_FROM_STRING is described at Qt documentation for QSettings Try to fix your issue using it. According to this description it will disables automatic conversions from QString (or char *) to QUrl.[/quote]

                I've just tried it, but it doesn't resolve my issue.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  leon.anavi
                  wrote on last edited by
                  #8

                  Have you tried to use the native format for MeeGo? I mean something like this:

                  @QSettings settings("file.desktop", QSettings::NativeFormat);@

                  http://anavi.org/

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    b0unc3
                    wrote on last edited by
                    #9

                    [quote author="leon.anavi" date="1330017302"]Have you tried to use the native format for MeeGo? I mean something like this:

                    @QSettings settings("file.desktop", QSettings::NativeFormat);@[/quote]

                    Yes, nothing changes.
                    I think I'll go with sed after the edit.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved