Hi,

I'm trying to connect to my database whit the following code:

Qt Code:
  1. #include <QSqlDatabase>
  2. ...
  3. QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
  4. db.setHostName("myhost");
  5. db.setDatabaseName("mydb");
  6. db.setUserName("myuser");
  7. db.setPassword("mypass");
  8. db.open();
To copy to clipboard, switch view to plain text mode 

but I'm getting this error:

main.cpp:5:24: QSqlDatabase: No such file or directory
main.cpp: In function `int qMain(int, char**)':
main.cpp:17: error: `QSqlDatabase' undeclared (first use this function)
main.cpp:17: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:17: error: expected `;' before "db"
main.cpp:18: error: `db' undeclared (first use this function)
mingw32-make[1]: *** [debug\main.o] Error 1