Hi,
Is it me, or is the columnCount() design poorly thought out?
The method is:
int QAbstractItemModel::columnCount( QModelIndex parent )
and yet, if you try to return a different # of columns depending on the parent, things don't work.
eg, I want a QTreeView with the root items to have one column (and spanned), and then the child items to all have 2 columns.
However, if you do this:
int Model::columnCount( QModelIndex parent )
{
if (parent.isValid())
return 2;
return 1;
}
And add the model to a treeview, then it will always only show 1 column.
So, apparently, trees are supposed to have a fixed number of columns.
Tables are obviously supposed to have a fixed number of columns.
and Lists usually have just 1 column.
So why pass the parent? its pointless and confusing, instead it should be
int Model::columnCount()
or am I missing something?
Paul
Bookmarks