PDA

View Full Version : Qsettings



jrideout
26th June 2006, 19:29
Before I implement it myself, does anybody know of a QSettings class that uses a database as a backend?

patrik08
26th June 2006, 20:07
Before I implement it myself, does anybody know of a QSettings class that uses a database as a backend?

no is only regedit or ini file...

jrideout
26th June 2006, 21:05
I know that is all the Trolls gave us, but has anybody out there written a derived class that uses a database?

wysota
26th June 2006, 22:58
Is it worth it? Just make a table in a database with two columns -- key and value and use insert, update and select to access them. Using an additional layer in this case is an overhead.

patrik08
27th June 2006, 00:38
I have write a gui setting to store static setting on a xml file .... full automatic....

qlineedit objektname = equival <objektname>value</objektname> ist fast.... same comobox

http://www.qtforum.de/forum/viewtopic.php?t=2192 you must read code and not german....:)

Brandybuck
27th June 2006, 05:59
Before I implement it myself, does anybody know of a QSettings class that uses a database as a backend?
Why do you want a database backend? QSettings is for settings, not application data, so I don't see why you would want it. If you have so many settings you need a database to manage them, then maybe it's time to rethink the solution.

jrideout
27th June 2006, 17:17
Why do you want a database backend? QSettings is for settings, not application data, so I don't see why you would want it. If you have so many settings you need a database to manage them, then maybe it's time to rethink the solution.

I'm extending an application that currently uses QSettings, both on a system level and and user, with the user settings overriding the system ones. The application is being rewritten to be deployed on different machines over the network, with the settings enforced by an administrator on a server. So, I was hoping that the easy way just to change the settings back-end. I have now, though, wrote my own class that has a similar api to QSettings that uses Qt's database classes as a back-end, but also flags settings as to whether or not a group can be overridden locally or must use the network provided setttings. Just synchronizing all the *.conf files on all the computers that use the system just wasn't an acceptable solution.

Brandybuck
27th June 2006, 19:13
The application is being rewritten to be deployed on different machines over the network...
Oh, I see now. In that case I think your tactic of writing your own class using the QSettings API is a good one.

wysota
27th June 2006, 22:06
Unfortunately simply subclassing QSettings won't help you because none of its methods are virtual. I think you should just implement a class simmilar to QSettings and substitute all occurences of QSettings in the code. Of course your class can still use QSettings to provide compatibility with the "usual" settings storage methods.

jrideout
27th June 2006, 23:18
Unfortunately simply subclassing QSettings won't help you because none of its methods are virtual. I think you should just implement a class simmilar to QSettings and substitute all occurences of QSettings in the code. Of course your class can still use QSettings to provide compatibility with the "usual" settings storage methods.


I ... wrote my own class that has a similar api to QSettings

Thanks, I did

fullmetalcoder
29th June 2006, 16:00
Unfortunately simply subclassing QSettings won't help you because none of its methods are virtual. I think you should just implement a class simmilar to QSettings and substitute all occurences of QSettings in the code. Of course your class can still use QSettings to provide compatibility with the "usual" settings storage methods.
Right but there is a static method called registerFormat() that allows the creation of custom settings format without changing anything in the API, just implementing to functions...

jrideout
29th June 2006, 20:21
Right but there is a static method called registerFormat() that allows the creation of custom settings format without changing anything in the API, just implementing to functions...

But, registerFormat() assumes that the format is of a file on the hard disk, you can't change that, of course you could set the file to /dev/null, or something but you'll have all sorts of issues or at least lost functionality with the conflict/locking stuff that Qsettings uses, plus it really isn't designed for it.

What I wanted was to store the data in a database, regardless of format (meaning I don't care about the format, not I want a generic use any format class). To do that I implemented a new (not derived) class which has a similar, but not entirely same api as QSettings, this enabled me to migrate a very large codebase over a day or so.