PDA

View Full Version : QtSql or QtSql/ ?



szisziszilvi
8th March 2011, 12:13
Hi,

I would like to try some simple database-connection. I opened the cachedtable example in the Creator which works fine. Then I started a brand new project, chose "Qt Gui application" and here is where I got lost... Ok, this is not my first Qt project, but this time there are things I can't get.

So. In the example there is
#include <QApplication>
In my one it is:
#include <QtGui/QApplication>
by default. First: what is the difference?

The second might be a related question.
There is the "connection.h" in that example, which I simply copied into my project. (Add new -> c++ source file -> and then simply copy-pasted the example header code, it's just the error message box that I throw out.) I included this file with #include "connection.h" in the mainwindow.h, and tried to build this project, but this did not work. It complains for all the included libraries in the heades saying "No such file or directory.".

I tryed to change the include lines like #include <QtSql/...> but it does not work at all.

So what do I not understand? I'm a bit confused... :S

wysota
8th March 2011, 12:16
Add QT+=sql to your project file.

szisziszilvi
8th March 2011, 13:00
wow:) why can the "I'm lost in the forest" questions always be answered in no more characters as many fingers one have...
anyway, I would still be interested in the question about this <QApplication> thing.

BalaQT
8th March 2011, 15:44
#include <QApplication>
In my one it is:
#include <QtGui/QApplication>
by default. First: what is the difference?
hi,
both are referring to the same file only. u can use any of them.
First one simply includes the QApplication.
The second one's meaning is:
There are many modules in QtGui. you are only loading the QtGui's QApplication module.
press f2 in QApplication word u will see this #include "qapplication.h" again press f2 in qapplication.h, u will get the exact header file location

hope it helps