当前位置: 代码迷 >> QT开发 >> QT sqlite解决办法
  详细解决方案

QT sqlite解决办法

热度:129   发布时间:2016-04-25 04:56:17.0
QT sqlite
我刚开始初学sqlite,程序这样写的
#include<QtSql/QSqlDatabase>
#include<QtSql/QSqlQuery>
...
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("guo.db");
..
最后提示我
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::defaultConnection'
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::addDatabase(QString const&, QString const&)'
/home/guozhixin/QTli/ini/dialog.cpp:48: undefined reference to `QSqlDatabase::~QSqlDatabase()'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::setDatabaseName(QString const&)'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::~QSqlDatabase()'
/home/guozhixin/QTli/ini/dialog.cpp:49: undefined reference to `QSqlDatabase::~QSqlDatabase()'

 请问各位这是怎么回事?

------解决方案--------------------
在pro文件中加入
QT+=sql
  相关解决方案