VS2008 与Qt编程 出现.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall问题

VS2008 与Qt编程 出现.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall问题


定义数据 QSqlTableModel *model;

添加对应的头文件 #include <QtSql/QtSql>

然后编译提示:

tablemodelform.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSqlTableModel::QSqlTableModel(class QObject *,class QSqlDatabase)" (__imp_??0QSqlTableModel@@QAE@PAVQObject@@VQSqlDatabase@@@Z) referenced in function "public: __thiscall TableModelform::TableModelform(class QWidget *,class QString const &)" (??0TableModelform@@QAE@PAVQWidget@@ABVQString@@@Z)
1>tablemodelform.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QSqlDatabase::QSqlDatabase(void)" (__imp_??0QSqlDatabase@@QAE@XZ) referenced in function "public: __thiscall TableModelform::TableModelform(class QWidget *,class QString const &)" (??0TableModelform@@QAE@PAVQWidget@@ABVQString@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QSqlTableModel::metaObject(void)const " (?metaObject@QSqlTableModel@@UBEPBUQMetaObject@@XZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall QSqlTableModel::qt_metacast(char const *)" (?qt_metacast@QSqlTableModel@@UAEPAXPBD@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QSqlTableModel::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QSqlTableModel@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QSqlTableModel::rowCount(class QModelIndex const &)const " (?rowCount@QSqlTableModel@@UBEHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall QSqlQueryModel::columnCount(class QModelIndex const &)const " (?columnCount@QSqlQueryModel@@UBEHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QSqlTableModel::data(class QModelIndex const &,int)const " (?data@QSqlTableModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::setData(class QModelIndex const &,class QVariant const &,int)" (?setData@QSqlTableModel@@UAE_NABVQModelIndex@@ABVQVariant@@H@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QSqlTableModel::headerData(int,enum Qt::Orientation,int)const " (?headerData@QSqlTableModel@@UBE?AVQVariant@@HW4Orientation@Qt@@H@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlQueryModel::setHeaderData(int,enum Qt::Orientation,class QVariant const &,int)" (?setHeaderData@QSqlQueryModel@@UAE_NHW4Orientation@Qt@@ABVQVariant@@H@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::insertRows(int,int,class QModelIndex const &)" (?insertRows@QSqlTableModel@@UAE_NHHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlQueryModel::insertColumns(int,int,class QModelIndex const &)" (?insertColumns@QSqlQueryModel@@UAE_NHHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::removeRows(int,int,class QModelIndex const &)" (?removeRows@QSqlTableModel@@UAE_NHHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::removeColumns(int,int,class QModelIndex const &)" (?removeColumns@QSqlTableModel@@UAE_NHHABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlQueryModel::fetchMore(class QModelIndex const &)" (?fetchMore@QSqlQueryModel@@UAEXABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlQueryModel::canFetchMore(class QModelIndex const &)const " (?canFetchMore@QSqlQueryModel@@UBE_NABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual class QFlags<enum Qt::ItemFlag> __thiscall QSqlTableModel::flags(class QModelIndex const &)const " (?flags@QSqlTableModel@@UBE?AV?$QFlags@W4ItemFlag@Qt@@@@ABVQModelIndex@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::sort(int,enum Qt::SortOrder)" (?sort@QSqlTableModel@@UAEXHW4SortOrder@Qt@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::submit(void)" (?submit@QSqlTableModel@@UAE_NXZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::revert(void)" (?revert@QSqlTableModel@@UAEXXZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::clear(void)" (?clear@QSqlTableModel@@UAEXXZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall QSqlQueryModel::queryChange(void)" (?queryChange@QSqlQueryModel@@MAEXXZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall QSqlTableModel::select(void)" (?select@QSqlTableModel@@UAE_NXZ)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::setTable(class QString const &)" (?setTable@QSqlTableModel@@UAEXABVQString@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::setEditStrategy(enum QSqlTableModel::EditStrategy)" (?setEditStrategy@QSqlTableModel@@UAEXW4EditStrategy@1@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::setSort(int,enum Qt::SortOrder)" (?setSort@QSqlTableModel@@UAEXHW4SortOrder@Qt@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::setFilter(class QString const &)" (?setFilter@QSqlTableModel@@UAEXABVQString@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QSqlTableModel::revertRow(int)" (?revertRow@QSqlTableModel@@UAEXH@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QSqlTableModel::updateRowInTable(int,class QSqlRecord const &)" (?updateRowInTable@QSqlTableModel@@MAE_NHABVQSqlRecord@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QSqlTableModel::insertRowIntoTable(class QSqlRecord const &)" (?insertRowIntoTable@QSqlTableModel@@MAE_NABVQSqlRecord@@@Z)
1>tablemodelform.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall QSqlTableModel::deleteRowFromTable(int)" (?deleteRowFromTable@QSqlTableModel@@MAE_NH@Z)


....共有36个错误


解决方法:

没有添加对应sql的.lib文件

在Project/Property Pages/Linker/Input/Additional Dependencies 中添加 QtSql4.lib

之后便没有报错了!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值