Wednesday, May 23, 2012

Using Qt with eclipse, #include <QSqlDatabase> leads to file not found

So I have started a new Qt console project;

everything so far has been working fine. I have eclipse set up with the integration, but i'm not actually using it, i have just included the relevant Qt directories so that my #include <QtGui> calls work.

These have all worked perfectly so far.

i can compile it either using eclipse's build option, or by doing

qmake -project

from the command line. Both work.

the include statements i have; are:

#include <QtGui>
#include <QApplication>

In two different files.

If i add anotherone though, i.e. #include <QSqldatabase> then eclipse recognises the include, and lets me initialise new variables, and use the QSqlDatabase classes. Everything seems fine - see here - eclipse screenshot

When i build the project though, it decides it can't see the files even though they are all there, see them here in the terminal too. And then eclipse puts red lines everywhere.

If i go into the directory, and attempt to do it all via the terminal, using the qmake -project; qmake; make then i get the same errors.

If however, I go into the .pro file created by qmake -project, and add the line QT += sql, and then do qmake; make, then all is fine and it works.

Why is qmake -project leaving out these files from the project file? I'd really rather not have to go in and manually add that line every time I build it...

No comments:

Post a Comment