PDA

View Full Version : GCC can't find QSqlDatabase!!



brevleq
28th October 2007, 16:27
I'm having a strange problem, gcc don't find the QSql libraries!!
Look my ManipulaBanco.h:

#ifndef MANIPULABANCO_H
#define MANIPULABANCO_H

#include <QMessageBox>
#include <QSqlError>
#include <QSqlDatabase>
#include <QSqlQuery>

class ManipulaBanco{
Q_OBJECT
public:
ManipulaBanco(void);
private:
bool conecta(void);
QSqlDatabase banco;
};

#endif

when I do make:

In file included from main.cpp:3:
bd/ManipulaBanco.h:5:21: error: QSqlError: Can't find this file or directory
bd/ManipulaBanco.h:6:24: error: QSqlDatabase: Can't find this file or directory
bd/ManipulaBanco.h:7:21: error: QSqlQuery: Can't find this file or directory
bd/ManipulaBanco.h:15: error: 'QSqlDatabase' does not name a type
bd/ManipulaBanco.h:9: warning: 'class ManipulaBanco' has virtual functions but non-virtual destructor
make: ** [main.o] Erro 1

You can see that QMessageBox was found but the others didn't!!

How can I resolve this??

marcel
28th October 2007, 16:57
Have you added QT += sql to your pro file?

jpn
28th October 2007, 16:59
Only core and gui modules are enabled by default. To enable sql, add

QT += sql
to the .pro file and re-run qmake.

Edit: d*mnit, forgot to preview :p

brevleq
28th October 2007, 21:52
Oh guys!! Thank you!!

Now I don't have any problem here!!

All time I do: q make -project I should re-edit the .pro file??

brevleq
28th October 2007, 22:04
I have another question for you. I compiled the program but like you can see, I don't have the postgre driver:

QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers:

Where I can find the driver and how I install it?? I'm using postgre-8.2

jpn
29th October 2007, 07:05
All time I do: q make -project I should re-edit the .pro file??
Usually you do "qmake -project" only once, at the beginning of the project. From there on, you just add new files to the .pro and re-create makefiles by running "qmake". There is no need to re-create the .pro every time, because, as you have noticed, you will lose all the changes you've done.


Where I can find the driver and how I install it?? I'm using postgre-8.2
You should build Qt with psql support. See "configure -help" for more details.