这是 qt 的另一个问题:我扩展了 QAbstractTableModel,但出现编译错误(我正在使用 cmake)
// file.h
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractTableModel>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
public:
TableModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
};
#endif
// file.c
#include "tableModel.h"
TableModel::TableModel(QObject *parent)
: QAbstractTableModel(parent){}
int TableModel::rowCount(const QModelIndex & ) const
{ return 1; }
int TableModel::columnCount(const QModelIndex & ) const
{ return 1;}
当我编译时,我得到:
在TableModel':
/partd/unusedsvn/unusedpkg/iface/tableModel.cpp:4: undefined reference to
TableModel' /partd/unusedsvn/unusedpkg/iface/tableModel.cpp:4 的函数 vtable 中:未定义引用vtable for TableModel'
collect2: ld returned 1 exit status
有人遇到同样的问题吗??