Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我QAbstractItemModel用来实现我的模型。我有一个父项,想用另一组子项替换它的子项。更换前后,我应该使用哪些模型方法?或者我应该发出什么模型信号?谢谢。
QAbstractItemModel
在模型中, parent 是父项的 QModelIndex,count 是要添加的子项的数量:
beginRemoveRows(parent, 0, rowCount(parent)); //remove from data endRemoveRows(); beginInsertRows(parent, 0, count); //add rows into data endInsertRows();