Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
QTSetting problem
Hello!
I'm trying to define my app's configuration file, but I can't find what's wrong in my code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#include <qsettings.h>
#include <qapplication.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QSettings settings;
settings.setPath( "MyCompany.com", "interface" );
int Rouge_Actif = settings.readNumEntry( "interface/Couleurs/Themes/Actif/Rouge", 640 );
qDebug(QString::number(Rouge_Actif));
[...]
|
Here is my file ~/.qt/interfacerc
|
Source code
|
1
2
3
|
[interface]
Couleurs/Themes/Actif/Bleu=251
Couleurs/Themes/Actif/Rouge=151
|
when I execute the program, it always gives me the default value ( 640 ) ...
Thank you very much!
Hi,
I don't know if your rc file has a correct layout. Have you tried to write the value using QSettings?
Michael.
QTSetting problem
yes, I've tried
settings.writeEntry("interface/Couleurs/Themes/Actif/Rouge", 640 );
it doesn't work
Try prepending / to all your paths so they start with it.
There is an example for QSettings usage in the Knowledge Database kdb.qtforum.org
Cheers,
_
Qt/KDE Developer
Debian User