PDA

View Full Version : QSettings Assignment



SixDegrees
30th April 2010, 22:32
I'll be using a QSettings object to store and save user preferences in an upcoming project. One request is to enable the user to simply "Apply" their preferences changes, rather than save them; such settings would be used until the end of the current session, or until the user changed them again, but settings that were "Save"d during a prior session would remain in effect in the future.

My first thought was to maintain two setting objects, one corresponding to the setting currently in use and possibly modified through "Apply," and another corresponding to the "Save"d settings. The simplest way to make this work would be to assign one QSettings object to the other as needed, so that only the persistent copy would be saved, but the other, possibly transient copy would be used by the program when when applying settings.

That won't work, however, because assignment and copy construction of this object is disallowed, and there is no 'clone' method.

Another approach would be to write a second backing store, but this seems needlessly complex.

Any thoughts on how best to accomplish this task?

waynew
30th April 2010, 23:00
One way would be to make two tables in SQLite - one for session and one for permanent.
It's easy code to store whatever settings you want - window positions, sizes, colors, font, etc.
Then just delete from the session table when the users closes the application.