I am trying to implement QAbstractItemModel for QTreeView. I have a problem inserting rows. I noticed that if I paste at the beginning of my application, everything works fine. But if I insert lines later - after some other operations (for example, selection, etc.) New elements remain invisible. Moreover, QTreeView doesn't seem to work at all! Do I have to emit some signals to notify QTreeView of row insertion?
This is my insert method:
bool LayersModel::insertRows(int position, int count, const QModelIndex & parent)
{
LayersModelItem * parentItem = getItem(parent);
if (position > parentItem->childCount())
return false;
beginInsertRows(parent,position,position+count-1);
bool result = true;
for (;count;--count)
result &= parentItem->insertChildren(position, new LayersModelItem());
endInsertRows();
return result;
}
LayersModelItem is a class with a QList with its children and data.
( KDE libs):
https://github.com/coder89/PhotoFramesEditor/tree/v0.0.8
, , " ". ( Canvas:: removeItems()), - , ... ( - ).
!