(1)具体的行更新
QModelIndex modelIndex = this->index(indexItem, 0, QModelIndex());
emit this->dataChanged(modelIndex, modelIndex);
其中indexItem为要更新的行索引。
同理,具体列更新如下:
QModelIndex modelIndex = this->index(0, indexItem, QModelIndex());
emit this->dataChanged(modelIndex, modelIndex);
其中indexItem为要更新的列索引。
(2)插入时触发行更新
beginInsertRows(QModelIndex(), pos, pos);
m_datas.insert(pos, itemInfo);
endInsertRows();
其中pos为要插入的位置,即在ListView中的第几项。itemInfo为要插入的内容。
同理,插入时触发列更新如下:
void beginInsertColumns(const QModelIndex &parent, int first, int last);
void endInsertColumns();
(4)整体更新
void beginResetModel();
void endResetModel();
(5)移除行后的更新
void beginRemoveRows(const QModelIndex &parent, int f
QModelIndex modelIndex = this->index(indexItem, 0, QModelIndex());
emit this->dataChanged(modelIndex, modelIndex);
其中indexItem为要更新的行索引。
同理,具体列更新如下:
QModelIndex modelIndex = this->index(0, indexItem, QModelIndex());
emit this->dataChanged(modelIndex, modelIndex);
其中indexItem为要更新的列索引。
(2)插入时触发行更新
beginInsertRows(QModelIndex(), pos, pos);
m_datas.insert(pos, itemInfo);
endInsertRows();
其中pos为要插入的位置,即在ListView中的第几项。itemInfo为要插入的内容。
同理,插入时触发列更新如下:
void beginInsertColumns(const QModelIndex &parent, int first, int last);
void endInsertColumns();
(4)整体更新
void beginResetModel();
void endResetModel();
(5)移除行后的更新
void beginRemoveRows(const QModelIndex &parent, int f