[SOLVED] unresolved external symbol
-
I get error ( and see my code below ) :
@SqlQueryModel.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual class QVariant __thiscall QAbstractItemModel::data(class QModelIndex const &,int)const " (_imp?data@QAbstractItemModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z) referenced in function "public: virtual class QVariant __thiscall SqlQueryModel::data(class QModelIndex const &,int)const " (?data@SqlQueryModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z)@
what am i doing wrong ?:
header :
@#ifndef SQLQUERYMODEL_H
#define SQLQUERYMODEL_H#include <QSqlQueryModel>
#include <QModelIndex>
#include <QAbstractItemModel>class SqlQueryModel : public QSqlQueryModel {
Q_OBJECTprivate:
public:
SqlQueryModel(QObject * parent = 0);
QVariant data(const QModelIndex & item, int role ) const;
public slots:};
#endif // SQLQUERYMODEL_H@
cpp :
@#include "SqlQueryModel.h"SqlQueryModel::SqlQueryModel(QObject *parent) : QSqlQueryModel(parent) {
}
QVariant SqlQueryModel::data(const QModelIndex & item, int role ) const {
if (item.column() == 1 && role == Qt::TextAlignmentRole) {
return Qt::AlignRight;
} else {
return QAbstractTableModel::data(item, role);
}
}@ -
Just to clarify for future reference:
QAbstractTableModel inherits from QAbstractItemModel, which only has a pure virtual data()-function. This means it does not have a default implementation of this function (it's "empty").
Since QAbstractTableModel doesn't then implement data() either, you can't actually use it directly (it's still "empty").
You can only inherit from QAbstractTableModel and then implement its functionality yourself. Or use a different class that comes with a working implementation of this function, as you did with QSqlQueryModel.