Persistent application configuration data.

Ralf Nolden Ralf.Nolden at post.rwth-aachen.de
Fri Mar 17 06:33:42 UTC 2000


"Miller, John JE" wrote:
> 
> Hi all,
> 
> In the Linux world where does one store application
> specific configuration data, ie the top/left co-ordinates
> of a window on the screen when the window is shutdown,
> so that it can be restored to that position the next time
> it is opened (dare I suggest, in the style of INI files on
> windows).  Anyone got a class to create/read/write/delete
> this data.

Before you get some other advice as I have read ;-) here´s some expert
help:
the class you want to use is KConfig. The templates for KDE apps already
use these in reading and writing options. the Geometry is already saved
for your application in saveOptions() and restored when starting up in
readOptions(). Look for QWidget methods to retrieve the topleft
position, store it in a QPoint and look for suitable methods to write
and read the point and set the position. You can use setGeometry(QRect)
instead of resize() which the normal templates use, where you can
specify the topleft position in the QRect.  Add your code to the
read/saveOptions() methods to ensure all goes well.

In KDE you NEVER need an INI file or something like that nor do you have
to take care for the actual location for the file. KConfig does that
completely for you, so use this class whenever you want to store/read
any options, e.g. key accelerators or whatever. Use setGroup() to
separate the config file into groups and watch out for ALWAYS giving
default values in the read methods like described in the KConfig API, so
your members don´t run uninitialized if the user starts your program the
first time.


Hope this helps,

Ralf

-- 
**********************************
Ralf Nolden

Ardennenstr. 41 
52355 Düren

Tel. 02421/502758

The KDevelop Project
http://www.kdevelop.org

Email: rnolden at kdevelop.de
**********************************





More information about the KDevelop mailing list