문제

I am using QAbstractItemModel to implement my model. I have a parent item and want to replace its child items with another set of child items. Before and after replacing, what model methods should I use? Or what model signals should I emit? Thanks.

도움이 되었습니까?

해결책

in the model with parent being the QModelIndex of the parent items and count being the amount of child items to add:

beginRemoveRows(parent, 0, rowCount(parent));
//remove from data
endRemoveRows();
beginInsertRows(parent, 0, count);
//add rows into data
endInsertRows();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top