Empty rows in QSortFilterProxyModel
-
wrote on 14 Jul 2014, 09:52 last edited by
Hi folks,
I'm using QSortFilterProxyModel to sort a custom model(inherit from QAbstractItemModel) which maintains a callstack tree. Data will dynamically inserted into this model by a custom interface called insert data(showed below).
@
void ProfModel::insertData(DWORD *stack, int depth, Counts counts)
{
ProfItem *curr = m_root_item;
curr->modData(counts);ProfItem *tmp;
for(int i=0; i<depth; i++)
{
tmp = curr->getChild(stack[i]);
if(tmp == NULL)
{
beginInsertRows(createIndex(curr->row(), 0, curr),
curr->childCount(), curr->childCount());
for(int j=i; j<depth; j++)
{
tmp = curr->createChild(stack[j]);
tmp->modData(counts);
m_queue->addParse(tmp);
curr = tmp;
}
endInsertRows();
return;
}
else
{
tmp->modData(counts);
curr = tmp;
}
}
}
@Everything goes as expected if I directly display my custom model into a QTreeView. But when I display my model through a QSortFilterProxyModel, randomly there were some empty rows inserted in the treeview. I'm sure that these empty rows are not exist in my custom model.
I've tried Qt4.7 and Qt4.8, but both of them came out with the same result.
Can anyone help me with this?
Thanks in advance.
Best
1/1