Hello.

I'm new to model view programming but I've successfully implemented a model inherited from QAbstractListModel:

Qt Code:
  1. class PaletteListModel : public QAbstractListModel
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit PaletteListModel(QList<QColor> colors, QObject *parent);
  7. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  8. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
  9. ...
  10. ...
  11. ...
  12. private:
  13. QList<QColor> m_colors;
  14.  
  15. };
  16.  
  17. PaletteListModel::PaletteListModel(QList<QColor> colors, QObject *parent) :
  18. {
  19. m_colors = colors;
  20. }
  21.  
  22. int PaletteListModel::rowCount(const QModelIndex & ) const
  23. {
  24. return m_colors.count();
  25. }
  26. ...
  27. ...
To copy to clipboard, switch view to plain text mode 

So I can pass a list which can have a dynamic length to the constructor which will be stored in a private field. With this I can determine the row count...

But how can I pass and store the data for a table model? I guess it has to be some kind of nested list. But I can't figure out how exactly to do this:

Qt Code:
  1. class PaletteTableModel : public QAbstractTableModel
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit PaletteTableModel(??????? colors, QObject *parent);
  7. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  8. int columnCount(const QModelIndex &parent = QModelIndex())) const;
  9.  
  10. private:
  11. ???????? m_colors;
  12.  
  13. };
  14.  
  15.  
  16. PaletteTableModel::PaletteTableModel(??????? colors, QObject *parent) :
  17. {
  18. m_colors = colors;
  19. }
  20.  
  21. int PaletteTableModel::rowCount(const QModelIndex & ) const
  22. {
  23. return ?????
  24. }
  25.  
  26. int PaletteTableModel::columnCount(const QModelIndex &) const
  27. {
  28. return ?????
  29. }
  30. ...
  31. ...
  32. ...
To copy to clipboard, switch view to plain text mode 

How do I have to implement this?