[Qt-interest] Data Storage for QT Application

John McClurkin jwm at nei.nih.gov
Tue Feb 9 14:19:09 CET 2010


Chitrang Srivastava wrote:
> Thanks All,
> I tried QSetting
> 
> my data is Country/Capital pair and number of entries can go upto 10-20.
> 
> setValue("Country/Name","France")
> setValue("Country/Capital","Paris")
> setValue("Country/Name","Japan")
> setValue("Country/Capital","Tokyo")
> 
> Now with QSetting it always overwrite the key Country/Name  with latest 
> value.
> This isn't I was looking, is their way in QSetting to works as database 
> with multiple value for same key?
> 
> Basically I am looking for mini database  in which I can read-all , 
> insert or search-and-delete a row.
> Do you guys think their is a way to do in QSettings ?
> Or I have to use some other API.
> I dont want to use QSql (may be bulky for this small data).
> 
> -Chits
This is the documented behavior. According to the documentation:

"If there already exists a setting with the same key, the existing value 
is overwritten by the new value."

What you may want is QMultiMap

> 
> 
> 
> 
> On Fri, Feb 5, 2010 at 4:04 PM, Ross Driedger <ross at earz.ca 
> <mailto:ross at earz.ca>> wrote:
> 
> 
>     On 5-Feb-10, at 2:16 AM, qt-interest-request at trolltech.com
>     <mailto:qt-interest-request at trolltech.com> wrote:
> 
>      > Thanks all, QSettings looks to be a favourite option.
>      > I will look at the API description ,
>      > Can you guys points to some example.
> 
>     Assistant is your friend. :)
> 
>      >
>      >> From what I read of QSetting it is used to save settings and then
>      >> retrive
>      > based on specific key.
>      > In may case their is no key.
>      > Its like this.All are string data.At application start I want to
>      > read the
>      > data and populate some UI component.Also need to delete any
>      > particular row
>      > or add another row.I know XML is one way but some how I found their
>      > API to
>      > be bit cryptic .
>      > Can this be done using QSettings?
> 
>     In either case of XML or QSettings, you will need t set up a key-value
>     relationship of some sort, even if the key makes no sense outside your
>     application,
> 
>     The QSettings API is pretty straight forward.  If you choose an XML
>     solution, you will need to learn about SAX and/or DOM, but on the
>     positive side, learning about XML is an important skill these days.
> 
>     Ross Driedger
>     ross_at_earz.ca <http://ross_at_earz.ca>
> 
> 
> 
> 
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> 



More information about the Qt-interest-old mailing list