summaryrefslogtreecommitdiff
path: root/examples/opiecore/oconfigdemo/oconfigdemo.cpp
blob: 2ee4a65665840e7454d2bd8f9fd877d1c9d4acf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
#include <qpe/config.h>

using namespace Opie::Core;

int main( int argc, char** argv )
{
    OApplication* app = new OApplication( argc, argv, "MyConfigDemoApplication" );

    OConfigGroupSaver c1( app->config(), "MyGroup" );
    app->config()->writeEntry( "AnEntry", "InMyGroup" );
    {
        OConfigGroupSaver c2( c1.config(), "AnotherGroup" );
        app->config()->writeEntry( "AnEntry", "InAnotherGroup" );
    }   // closing the scope returns to the last group

    app->config()->writeEntry( "AnotherEntry", "InMyGroup" );

    // do more stuff ...

    // in this (special) case it is necessary to manually call OConfig::write() (see below)
    app->config()->write();

    // can't delete the app when using the OConfigGroupSaver on top level scope,
    // because the destructor of the OConfigGroupSaver needs an application object
    //delete app; // destructor deletes config which writes changes back to disk

    return 0;

}