PDA

View Full Version : How can i use QSettings in my MFC application?



tiongsquare
18th July 2011, 17:10
is it possible? if yes how will i need to declare the class,object and include what headers in my initialization func of my mfc main class? thanks! :)

high_flyer
18th July 2011, 17:17
is it possible?
Yes, but the question is why do you want to mix MFC and Qt?
You better stay with one of the two all the way, mixing them is asking for trouble.

if yes how will i need to declare the class,object and include what headers in my initialization func of my mfc main class?
Qt is a library, just like any other (in general).
So you will have to link to Qt.
As long as you don't use signals and slots, and really just use QSettings, you might get away with out the need to construct QCoreApplication object.
You will have to include <QSettings>.
For using QSettings, read here : QSettings.
There may come some other problems - you are welcome to try and see.

tiongsquare
18th July 2011, 17:59
Yes, but the question is why do you want to mix MFC and Qt?
You better stay with one of the two all the way, mixing them is asking for trouble.

Qt is a library, just like any other (in general).
So you will have to link to Qt.
As long as you don't use signals and slots, and really just use QSettings, you might get away with out the need to construct QCoreApplication object.
You will have to include <QSettings>.
For using QSettings, read here : QSettings.
There may come some other problems - you are welcome to try and see.

thanks for your reply!! :)
btw if i want to use QTimer too, there is the signal and slot needed for the handler
so i will need to create the QcoreApplication object?

tiongsquare
19th July 2011, 02:21
I'm having this problem when i try to #include <QSettings> in my application

1>c:\qt\4.6.2\include\qtcore\../../src/corelib/io/qsettings.h(45) : fatal error C1083: Cannot open include file: 'QtCore/qobject.h': No such file or directory

i checked the files in there and qobject.h is in QtCore folder, so whats what now? anyone help?

high_flyer
19th July 2011, 11:43
btw if i want to use QTimer too, there is the signal and slot needed for the handler
so i will need to create the QcoreApplication object?
Yes.


i checked the files in there and qobject.h is in QtCore folder, so whats what now? anyone help?
the ../../ should not be in the path, the path is wrong.

You didn't answer why you are mixing MFC and Qt?
Why not do everything in Qt?
Will save you a lot of trouble.