ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like it if some of you experienced guys could give me some hints, or show me some reading on how to store settings in a KDE C++ application. I have been thinking about using some sort of readable config-file but I figured that that is not necessary, I could as well store them in binary somewhere. Is there any well-known method on how to approach such a problem? I would like to make my application "KDEish", so that it won't be too much of a hazzle to learn just because I use "my own methods". If you understand what I mean.
since its just a value pair you need casting like
readNumEntry()
readSizeEntry()
readBoolEntry()
and you can set a default for if the read fails like
myOtherClass->setBooleanThingy(kconfig->readBoolEntry("boolean_thingy",false));
or whatever -- KDE is so easy to use it ought to be a crime
I like the KConfig way. I have one problem with it, tho. Since my application is Qt4 it seems I cannot use it.
After a qmake-qt4 -project && qmake-qt4 I have a Makefile done and ready. kconfig.h (which I assume is the file I need to include if I want to use KConfig) exists in /usr/include/kde, so I add -I/usr/include/kde to the INCPATH in the Makefile. However, I also need to add -I/usr/include/qt3 since some headers (like qstrlist.h) is needed by the kconfig-headers.
I have the same problem when trying to use KParts, which also forces me to include /usr/include/qt3. With this dir included in the Makefile I get following the errors:
Code:
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -Isrc -I. -I. -I/usr/include/kde -I/usr/include/qt3 -o main.o src/main.cpp
/usr/include/qt3/qtextstream.h:53: error: invalid function declaration
/usr/include/qt3/qtextstream.h:196: error: 'QTextStream' does not name a type
/usr/include/qt3/qtextstream.h:198: error: invalid function declaration
/usr/include/qt3/qtextstream.h:214: error: invalid function declaration
/usr/include/qt3/qtextstream.h:234: error: 'QTextStream' has not been declared
/usr/include/qt3/qtextstream.h:234: error: non-member function 'QIODevice* device()' cannot have cv-qualifier
/usr/include/qt3/qtextstream.h: In function 'QIODevice* device()':
/usr/include/qt3/qtextstream.h:235: error: 'dev' was not declared in this scope
/usr/include/qt3/qtextstream.h: At global scope:
/usr/include/qt3/qtextstream.h:237: error: 'QTextStream' has not been declared
/usr/include/qt3/qtextstream.h:237: error: non-member function 'bool atEnd()' cannot have cv-qualifier
/usr/include/qt3/qtextstream.h: In function 'bool atEnd()':
/usr/include/qt3/qtextstream.h:238: error: 'dev' was not declared in this scope
/usr/include/qt3/qtextstream.h: At global scope:
/usr/include/qt3/qtextstream.h:240: error: 'QTextStream' has not been declared
/usr/include/qt3/qtextstream.h:240: error: non-member function 'bool eof()' cannot have cv-qualifier
/usr/include/qt3/qtextstream.h:243: error: 'QTextStream' has not been declared
/usr/include/qt3/qtextstream.h:243: error: non-member function 'int flags()' cannot have cv-qualifier
..and the list of errors goes on. My assumption is that the Qt3 headers conflicts with the Qt4 headers and prevent my application from being compiled. However, this seems wrong to me. Shouldn't I be able to build an application that is built upon Qt4 but which can be used with KDE 3.x? Will I have to wait for some KDE4 pre-betas if I want to intergrate my Qt4 app with KDE?
I am not too familiar with how Qt3 differs from Qt4 but maybe it is enough to make it impossible to make a Qt4 app for KDE 3. If someone can just confirm this so I can go back to Qt3 and wait for Qt4 apps until KDE4 is coming somewhere (although if I would prefer it if someone could tell me "do this" and I would be able to keep using Qt4 ;).
But, I might as well ask here, since I cannot find it in the manual: is there any shortcuts with the editing of the Makefile (where I had to add some includes)? Can I make qmake add some directories to the INCPATH? As it is now I have to manually edit the Makefile after every time I run qmake.
It seems that KConfig did not work. I get a segfault using the same code I got, including kconfig.h and kglobal.h, and adding -lkdecore to the linker. The only guide I could find for kconfig was the KConfig XT guide which seemed a little too complicated and assumed that I had worked with KConfig earlier.
Is there any good guide out there that introduces kconfig, for people like me whom have never used kconfig before? The code I got earlier in this thread made kconfig look like a play, easy to store and easy to retrieve. However, the KConfig XT guide made me believe that it is far from that easy, I will have to create a xml file, a .kcfgc file and convert it into c++ code, etc.
I like KDE, but seriously, the documentation for developers is far from satisfying. I don't know anything about how to use kparts or how to use kconfig, and I can't find any documentation on it either. Maybe I should stop doing this and program for Gnome instead? Or Windows (say what you want about it, but at least you have some good reading there).
sorry i didn't know it was qt only app i have never tried to do these things without using
KApplication
as the application object so that might be the solution
sorry i didn't know it was qt only app i have never tried to do these things without using
KApplication
as the application object so that might be the solution
I will look into that KApplication, it sounds like something I could need. :)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.