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
qmake
make
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...
Why is qmake -project leaving out these files from the project file?
As far as I know, qmake isn't supposed to replace human programmer. If you want to know WHY it doesn't detect SQL dependency, you can read qmake source code.
I'd really rather not have to go in and manually add that line every time I build it...
It sounds like you're trying to do something weird here. You don't need to call qmake -project before every build.
qmake -project
generates initial project - *pro file. Once initial project has been generated, you can tweak it, and add options or some macro magic if you want. Then, using *.pro file, you generate script for your build system (vcproj for windows, makefiles for windows/*nix, nmake make files, etc).
Workflow goes like this:
qmake -project
.qmake
To simply "build" all you have to do is #2.3. You call qmake
(without -project) switch only if you modified *.pro file.
See qt documentation and tutorials for more info.