[Qt-interest] EditableTreeMode example crashing with modeltest
Jan
janusius at gmx.net
Tue Nov 24 11:45:35 CET 2009
Daniel Price schrieb:
> QModelIndex TreeModelAdaptor::index(int row, int column, const QModelIndex &parent) const
> {
> if (parent.isValid() && parent.column() != 0)
> return QModelIndex();
>
> ....
> }
>
> This was copied from the example - the test passes in a valid parent with a non-zero column and gets back an invalid model index, triggering the assert. But my model code is almost identical to the example.
>
> Can someone explain this code? Why does the code return the root item in this case?
I suppose because if the column is > 0 it usually should not have a
parent (and therefore has no valid index) - only a sibling in column 0.
Maybe make sure you provide as much item data as you have columns
(headers) in the root item
QVector<QVariant> rootData;
foreach (QString header, headers)
rootData << header;
Jan
More information about the Qt-interest-old
mailing list