Hi,

I'm trying to figure out how best to make my own model class but I'm going round in circles figuring out what to inherit from and what to reimplement.

Currently I have it inheriting from QStandardItemModel like so:

Qt Code:
  1. class PlayersModel : public QStandardItemModel
  2. {
  3. Q_OBJECT
  4. public:
  5. PlayersModel(QObject* parent = 0);
  6. };
To copy to clipboard, switch view to plain text mode 

And then the constructor is set up like so:

Qt Code:
  1. PlayersModel::PlayersModel(QObject* parent) : QStandardItemModel(0, 2, parent)
  2. {
  3. this->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));
  4. this->setHeaderData(1, Qt::Horizontal, QObject::tr("Email"));
  5. }
To copy to clipboard, switch view to plain text mode 

But then I am aware that the user of PlayersModel could use the add column functions which I don't want them to be able to do. I simple want to define a list of name and email address (and maybe other things later).

Can anyone point me in the right direction of a tutorial (or just simply help by giving me a bit of code to help) which I can use to learn this? I've tried the model view tutorial in the Qt docs but it doesn't really explain what I need.

I would also like to be able to perform drag and drop between table view classes using the same model, which I have no idea how to implement at the moment but am keeping that in mind for now incase it has a bearing on how to implement my model class.

Thanks so much guys!