forked from PCMan/lxqt-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
86 lines (70 loc) · 2.97 KB
/
main.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <QCoreApplication>
#include "liblxqt-settings.h"
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
app.setOrganizationName("lxde");
app.setApplicationName("setting_test");
{
LxQt::Settings settings;
settings.beginGroup("testGroup");
QVariant v = settings.value("Test");
qDebug("value: %d", v.isValid());
settings.endGroup();
settings.beginGroup("testGroup2");
settings.setValue("TestStr", "Test");
settings.setValue("TestInt", 123);
settings.setValue("TestBool", true);
settings.setValue("TestFloat", 123.45);
qDebug() << "group: " << settings.group();
settings.endGroup();
settings.beginGroup("/testGroup2/testGroup3/");
qDebug() << "group: " << settings.group();
settings.setValue("TestStr", "Test2");
settings.endGroup();
settings.sync();
Q_FOREACH (QString key, settings.allKeys())
qDebug() << "key: " << key;
settings.beginGroup("testGroup2");
Q_FOREACH (QString key, settings.allKeys())
qDebug() << "testGroup2/key: " << key;
qDebug() <<"read TestStr: " << settings.value("TestStr").toString();
qDebug() <<"read TestInt: " << settings.value("TestInt").toInt();
qDebug() <<"read TestBool: " << settings.value("TestBool").toBool();
qDebug() <<"read TestFloat: " << settings.value("TestFloat").toFloat();
qDebug() <<"read testGroup3/TestStr: " << settings.value("testGroup3/TestStr").toString();
settings.endGroup();
}
{
QSettings settings;
settings.beginGroup("testGroup");
QVariant v = settings.value("Test");
qDebug("value: %d", v.isValid());
settings.endGroup();
settings.beginGroup("testGroup2");
settings.setValue("TestStr", "Test");
settings.setValue("TestInt", 123);
settings.setValue("TestBool", true);
settings.setValue("TestFloat", 123.45);
qDebug() << "group: " << settings.group();
settings.endGroup();
settings.beginGroup("/testGroup2/testGroup3/");
qDebug() << "group: " << settings.group();
settings.setValue("TestStr", "Test2");
settings.endGroup();
settings.sync();
Q_FOREACH (QString key, settings.allKeys())
qDebug() << "key: " << key;
settings.beginGroup("testGroup2");
Q_FOREACH (QString key, settings.allKeys())
qDebug() << "testGroup2/key: " << key;
qDebug() <<"read TestStr: " << settings.value("TestStr").toString();
qDebug() <<"read TestInt: " << settings.value("TestInt").toInt();
qDebug() <<"read TestBool: " << settings.value("TestBool").toBool();
qDebug() <<"read TestFloat: " << settings.value("TestFloat").toFloat();
qDebug() <<"read testGroup3/TestStr: " << settings.value("testGroup3/TestStr").toString();
settings.endGroup();
}
// return app.exec();
}