I think I figured out why it wasn't working - can't remember what it was now, but it seems to be fine.
Now I have yet another problem... I have switched to using a QTreeView because that seems actually to be more what I want. I don't actually have a tree structure, but the view looks better than a QTableView for my functionality.
But my custom model I have created doesn't work properly. Basically whenever I add an item, it gets put into the list, but also as a child of itself, and thus a child of that, and so on and so on. Adding another new entry makes that a child of the first, and etc, etc. It's really odd.
I'm fairly sure this is something to do with the way my index() and parent() functions are defined. Currently they are thus:
{
return createIndex(row, column);
}
{
}
QModelIndex PlayersModel::index(int row, int column, const QModelIndex &parent) const
{
return createIndex(row, column);
}
QModelIndex PlayersModel::parent(const QModelIndex &index) const
{
return QModelIndex();
}
To copy to clipboard, switch view to plain text mode
Any ideas what I am doing wrong?
Bookmarks