Pergunta

I'm implementing my model based on QAbstractItemModel and I'm using it with QTreeView to display hierachical data. Data are stored in sqlite table.

My question is how should I call beginInsertRows when adding subnodes. Lets say I have some parent node, it contains 10 subnodes. And I want to add new subnode (at the end).

I'm doing it like this:

beginInsertRows(parentIndex, currentNodesCount, currentNodesCount);
// actual inserting
endInsertRows()

currentNodesCount contains value 10 which is the number of rows in this subnode. The new node will be placed at the 11th position (10th counting from 0).

Is this logic correct ?

Thanks for help.


I'm wondering also about using beginRemoveRows.

Is this correct:

beginRemoveRows(parentIndex, currentRow, currentRow);
// delete record
endRemoveRows();

currentRow contains position in the list of the removed node counting from 0.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top