[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_OBJECT

    private:

    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);
    }
    }@



  • Does this compile for anyone ?



  • Hi,

    if you replace this ligne code :
    @
    return QAbstractTableModel::data(item, role);
    @

    with this one :

    @
    return QSqlQueryModel::data(item, role);
    @

    it will compile !



  • Thank you ! That works .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.