Hi,
I'm using qt4 from few weeks.
I've read the model subclassing reference page, and I've wrote my model.
The problem is that the compiler says: "cannot declare variable ‘model’ to be of abstract type ‘DMapLayerModel" on this instruction
Qt Code:
  1. DMapLayerModel model(obj)
To copy to clipboard, switch view to plain text mode 

The file DMapLayerModel.h is:

Qt Code:
  1. #ifndef DMAPLAYERMODEL_H_
  2. #define DMAPLAYERMODEL_H_
  3.  
  4. #include <QtCore>
  5. #include <QtGui>
  6. #include "DMapLayerObject.h"
  7.  
  8. class DMapLayerModel : public QAbstractItemModel{
  9. Q_OBJECT
  10. public:
  11. DMapLayerModel(DMapLayerObject *layers, QObject *parent = 0);
  12. virtual ~DMapLayerModel();
  13. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  14. QVariant data(const QModelIndex &index, int role) const;
  15. QVariant headerData(int section, Qt::Orientation orientation,
  16. int role = Qt::DisplayRole) const;
  17. Qt::ItemFlags flags(const QModelIndex &index) const;
  18. bool setData(const QModelIndex &index, const QVariant &value,
  19. int role = Qt::EditRole);
  20. bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
  21. bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
  22.  
  23. private:
  24. DMapLayerObject *layers;
  25.  
  26. };
  27.  
  28. #endif /* DMAPLAYERMODEL_H_ */
To copy to clipboard, switch view to plain text mode 

and the DMapLayerModel.cpp is:

Qt Code:
  1. #include "DMapLayerModel.h"
  2.  
  3. DMapLayerModel::DMapLayerModel(DMapLayerObject *layers, QObject *parent)
  4. : QAbstractItemModel(parent), layers(layers){
  5. }
  6.  
  7.  
  8. DMapLayerModel::~DMapLayerModel(){
  9.  
  10. }
  11.  
  12. int DMapLayerModel::rowCount(const QModelIndex &parent) const{
  13. int count=layers->getLayersNameList()->count();
  14. return count;
  15. }
  16.  
  17. QVariant DMapLayerModel::data(const QModelIndex &index, int role) const{
  18. if (!index.isValid())
  19. return QVariant();
  20.  
  21. if (index.row() >=layers->getLayersNameList()->size())
  22. return QVariant();
  23.  
  24. if (role == Qt::DisplayRole)
  25. return QVariant::fromValue(layers->getLayersNameList()->at(index.row()));
  26. else
  27. return QVariant();
  28.  
  29. }
  30.  
  31. QVariant DMapLayerModel::headerData(int section, Qt::Orientation orientation,
  32. int role) const{
  33.  
  34. if (role != Qt::DisplayRole)
  35. return QVariant();
  36.  
  37. if (orientation == Qt::Horizontal)
  38. return layers->getName();
  39. else
  40. return layers->getName();
  41. }
  42.  
  43. Qt::ItemFlags DMapLayerModel::flags(const QModelIndex &index) const{
  44.  
  45. if (!index.isValid())
  46. return Qt::ItemIsEnabled;
  47.  
  48. return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
  49.  
  50. }
  51.  
  52. bool DMapLayerModel::setData(const QModelIndex &index, const QVariant &value,
  53. int role){
  54.  
  55. if (index.isValid() && role == Qt::EditRole) {
  56. layers->getLayersNameList()->replace(index.row(), value.toString());
  57. emit dataChanged(index, index);
  58. return true;
  59. }
  60. return false;
  61. }
  62.  
  63. bool DMapLayerModel::insertRows(int position, int rows, const QModelIndex &index){
  64. return true;
  65. }
  66.  
  67. bool DMapLayerModel::removeRows(int position, int rows, const QModelIndex &index){
  68. return true;
  69. }
To copy to clipboard, switch view to plain text mode 

I'm a bit confused.
Thanks in advance.
M.