Results 1 to 6 of 6

Thread: GCC can't find QSqlDatabase!!

  1. #1
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry GCC can't find QSqlDatabase!!

    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??

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: GCC can't find QSqlDatabase!!

    Have you added QT += sql to your pro file?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: GCC can't find QSqlDatabase!!

    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
    J-P Nurmi

  4. #4
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: GCC can't find QSqlDatabase!!

    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??

  5. #5
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: GCC can't find QSqlDatabase!!

    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

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: GCC can't find QSqlDatabase!!

    Quote Originally Posted by brevleq View Post
    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.

    Quote Originally Posted by brevleq View Post
    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.
    J-P Nurmi

Similar Threads

  1. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.