Results 1 to 10 of 10

Thread: Qsettings does not differentiate between string and int values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Qsettings does not differentiate between string and int values

    That is correct for both questions!

    What is a backend?
    Are you referring to QSettings::SetIniCodec?

    I have an idea, I have seen QT add quotes at one time to. I think it was when I played with QSringList.
    Thinking of storing strings as QStringList of length 0. QVariant::type() will probably return the correct value.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qsettings does not differentiate between string and int values

    Quote Originally Posted by yaronkle View Post
    What is a backend?
    Are you referring to QSettings::SetIniCodec?
    No, QSettings would be one possible backend for storing values.

    Other alternatives would be JSON, XML or some custom storage format, e.g. using QDataStream.
    Even with QSettings as the backend, you could store the type as a subkey of the value.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2013
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default SOLVED: Qsettings does not differentiate between string and int values

    I have a working solution which was simpler than expected.

    When writing string values to the INI file, I append "\"STRING" to the string
    When reading generic values. If the QVariant is a string without the above prefix I assume it's an int.
    Works like a charm.

    Many thanks to all of you!
    Last edited by yaronkle; 15th October 2013 at 09:31.

Similar Threads

  1. How to convert string hex values to its real binary values?
    By AttilaPethe in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 22:47
  2. Replies: 2
    Last Post: 1st December 2011, 20:09
  3. Replies: 2
    Last Post: 10th December 2009, 20:51
  4. convert string to byte values
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 14:06
  5. Replies: 1
    Last Post: 27th August 2007, 13:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.