Qt-interest Archive, March 2002
way to flush QSettings?
Message 1 in thread
- Subject: way to flush QSettings?
- From: Jeff Shipman <shippy@xxxxxxx>
- Date: Sun, 24 Mar 2002 12:13:50 -0700
- Organization: New Mexico Institute of Mining and Technology
- To: Qt Mailing List <qt-interest@xxxxxxxxxxxxx>
It seems to me that QSettings doesn't write to file
until you exit the application. I find this
undesirable because I need to share data stores in
the QSettings across multiple dialogs that are
created and destroyed at different times. This means
I would need to make some sort of global variable
to hold all of this while I'm running the program.
This is kinda ugly. Is there a way to force QSettings
to dump out its information?
I'm using Qt-3.0.3 under Linux.
--
[ signature omitted ]
Message 2 in thread
On Sun, 24 Mar 2002 12:13:50 -0700
Jeff Shipman <shippy@nmt.edu> wrote:
> This is kinda ugly. Is there a way to force QSettings
> to dump out its information?
Although not fully explicit, it is written in the doc :
QSettings::~QSettings ()
Destroys the settings object. All modifications made to the settings will
automatically be saved.
Judging from the examples they give, a typical use would be something like
{ // open scope block
QSettings s;
// do whatever you want here
} // end scope block, QSettings is automatically deleted and preferences
are saved
Alternately, you can encapsulate a QSettings* in a globally accessible
class, with a save() method that will delete (thus saving the preferences)
and reallocate the QSettings object.
--
[ signature omitted ]
Message 3 in thread
Matthieu Dazy <dazy@t-surf.com>
> Alternately, you can encapsulate a QSettings* in a globally accessible
> class, with a save() method that will delete (thus saving the preferences)
> and reallocate the QSettings object.
Inelegant, I think. Why not just keep the QSettings and always access the
persistent variable?
Don't think of QSettings as an input/output thing. Think of it as a holder
of variables. Even during the program's running, QSettings holds the
_real_ copy of the variables.
--Arnt
Message 4 in thread
On Mon, 25 Mar 2002 14:23:18 +0100
Arnt Gulbrandsen <arnt@gulbrandsen.priv.no> wrote:
> Matthieu Dazy <dazy@t-surf.com>
> > Alternately, you can encapsulate a QSettings* in a globally accessible
> > class, with a save() method that will delete (thus saving the
> > preferences) and reallocate the QSettings object.
>
> Inelegant, I think. Why not just keep the QSettings and always access
> the persistent variable?
>
> Don't think of QSettings as an input/output thing. Think of it as a
> holder of variables. Even during the program's running, QSettings holds
> the_real_ copy of the variables.
Sure, but the point is that sometimes people want to be able to actually
save the values without quitting the application (e.g. a User preferences
dialog with a "save preferences" button). And this means being able to
destroy the QSettings object on demand.
--
[ signature omitted ]