Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSettings with QDateTime changes between 5..3.2 and 5.8
Qt 6.11 is out! See what's new in the release blog

QSettings with QDateTime changes between 5..3.2 and 5.8

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.0k 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.
  • RichardR Offline
    RichardR Offline
    Richard
    wrote on last edited by Richard
    #1

    Hi all,
    I just upgraded from QT 5.3.2 to 5.8 and Iam writing settings to an ini file on Windows10. I encounter compatibility problems between the two versions.

    When I save it like this:

    settings.setValue("recentfiles/AccessDate", info.LastAccessTime);
    

    Then with 5.3.2 it will save in my ini file:

    AccessDate=@Variant(\0\0\0\x10\0%\x80\xd1\x1\xfd\xc3/\xff)
    

    But with 5.8 it will write:

    AccessDate=@DateTime(\0\0\0\x10\0\x80\0\0\0\0\0\0\0\xff\xff\xff\xff\0)
    

    Reading it like this

    info.LastAccessTime  = settings.value("AccessDate").toDateTime();
    

    Works ok for 5.8 for both dialiects but the 5.3.2 fails to read the newer @QDateTime
    Is there a fix to this? I was hoping to remain compatible.

    RichardR 1 Reply Last reply
    0
    • RichardR Richard

      Hi all,
      I just upgraded from QT 5.3.2 to 5.8 and Iam writing settings to an ini file on Windows10. I encounter compatibility problems between the two versions.

      When I save it like this:

      settings.setValue("recentfiles/AccessDate", info.LastAccessTime);
      

      Then with 5.3.2 it will save in my ini file:

      AccessDate=@Variant(\0\0\0\x10\0%\x80\xd1\x1\xfd\xc3/\xff)
      

      But with 5.8 it will write:

      AccessDate=@DateTime(\0\0\0\x10\0\x80\0\0\0\0\0\0\0\xff\xff\xff\xff\0)
      

      Reading it like this

      info.LastAccessTime  = settings.value("AccessDate").toDateTime();
      

      Works ok for 5.8 for both dialiects but the 5.3.2 fails to read the newer @QDateTime
      Is there a fix to this? I was hoping to remain compatible.

      RichardR Offline
      RichardR Offline
      Richard
      wrote on last edited by
      #2

      I Just found out that it must be related to this issue:
      https://codereview.qt-project.org/#/c/126279/

      jsulmJ 1 Reply Last reply
      1
      • RichardR Richard

        I Just found out that it must be related to this issue:
        https://codereview.qt-project.org/#/c/126279/

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Richard I would use http://doc.qt.io/qt-5/qdatetime.html#toString and specify format. This way you do not depend on how Qt is serializing QDateTime. And it is readable by humans :-)

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

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