Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, August 2007
(Qt4.1.0,eclipse CDT,mac)no database access


Message 1 in thread

Hello,

I wonder why there is an error in the following program:

#include <QMessageBox>  
#include <QtGui>
#include <QSqlDatabase>   *
#include <QtSql>   *

int main(int argc,char* argv[]){
    QSqlDatabase db;   *
    db=QSqlDatabase::addDatabase("QMYSQL");   *
    db.setHostName("localhost");
    db.setDatabaseName("mysql");
    db.setUserName("root");
    db.setPassword("root");
    if (!db.open())
        QMessageBox::critical(0,"Database error",db.lastError().text());
   
   
}

the errors concern the lines where there is a star(line 3:"no such file 
or directory"); it seems clear that there is a problem concerning the 
importation of the QtSql library; but the library QtSQL is declared in 
the include folder, like e.g. QtGui (present in the program above): it 
should be recognized.




Have you got an idea of what's going wrong?

lolveley.

--
 [ signature omitted ] 

Message 2 in thread

lolveley a écrit :
> Hello,
>
> I wonder why there is an error in the following program:
>
> #include <QMessageBox>  #include <QtGui>
> #include <QSqlDatabase>   *
> #include <QtSql>   *
>
> int main(int argc,char* argv[]){
>    QSqlDatabase db;   *
>    db=QSqlDatabase::addDatabase("QMYSQL");   *
>    db.setHostName("localhost");
>    db.setDatabaseName("mysql");
>    db.setUserName("root");
>    db.setPassword("root");
>    if (!db.open())
>        QMessageBox::critical(0,"Database error",db.lastError().text());
>     }
>
> the errors concern the lines where there is a star(line 3:"no such 
> file or directory"); it seems clear that there is a problem concerning 
> the importation of the QtSql library; but the library QtSQL is 
> declared in the include folder, like e.g. QtGui (present in the 
> program above): it should be recognized.
>
>
>
>
> Have you got an idea of what's going wrong?
>
> lolveley.
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
hello,

a short answer for this issue: I have found the solution: I added the 
line QT += sql in the .pro file of the project, with the purpose of 
using the databases, and IT WORKED!

lolveley.

--
 [ signature omitted ]