PDA

View Full Version : TreeModel: removing items will make the expand/collapse button vanish



ZHawk
3rd February 2011, 21:54
hi,

i have a treemodel which is actually working fine, except removing.
how it looks like:

HEADLINE (expanded view)
group1
item1
item2
item3
group2
itemA
itemB

HEADLINE (collapsed view group1)
group1
group2
itemA
itemB
adding is working fine.
removing items from any expanded group does work fine.

BUT if "group1" is collapsed and i remove an item (eg: "item3"), then the button infront of "group1" will vanish.
i can still press that invisible button to expand "group1".
when i add another item to "group1" the button will appear BUT only if it is expanded.

other groups are not affected until i remove item out of them


bool TreeModel::insertRows( int row , int count , const QModelIndex &parent )
{
TreeItem *parentItem = getItem(parent);
beginInsertRows(parent, row, row + count - 1);
parentItem->appendChild(tmpItem);
endInsertRows();
return true;
}
bool TreeModel::removeRows( int row , int count , const QModelIndex &parent )
{
TreeItem *parentItem = getItem(parent);
beginRemoveRows(parent, row, row + count - 1);
parentItem->removeChild(tmpItem);
endRemoveRows();
return true;
}

any help or ideas ?

ZHawk
4th February 2011, 01:41
btw:
just tested it with linux and there it is working fine. the button is a rectangle with a cross inside
i am using win7 and the button is a triangle.