阅读 Qt Assistant 后,我制作了这些对象
#include "account.h"
#include<QtSql/QSqlDatabase>
#include<QtSql/QSqlQuery>
Account::Account(QWidget *parent)
: QMainWindow(parent)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
QSqlQuery q(db);
q.exec("CREATE TABLE my");
}
运行后我得到这些错误:
error: undefined reference to `QSqlDatabase::defaultConnection'
error: undefined reference to `QSqlDatabase::addDatabase(QString const&, QString const&)'
error: undefined reference to `QSqlQuery::QSqlQuery(QSqlDatabase)'
error: undefined reference to `QSqlQuery::exec(QString const&)'
以及关于析构函数的其他错误:
error: undefined reference to `QSqlDatabase::~QSqlDatabase()'
.........