PDA

View Full Version : removing an item from a treeWidget



user
13th November 2008, 01:19
My treeWidget looks something like this:
-------------------------
mission1

configuration
charts
mission2

configuration
charts
-------------------------

I can add and remove as many missions as I want.

When I remove a selected mission via: treeWidget->takeTopLevelItem(itemIndex);
the slot currenItemChanged which I have connected to find out details about the new current item, is called with the new current item in the treeWidget.

This works when I have the 2 missions (as above) and I remove mission2 by right click action. When currenItemChanged is called I can access the current item which is now mission1 and indexOfTopLevelItem( current) returns 0.

My problem is when I have the 2 missions (as above) and I remove mission1. When currenItemChanged is called I can access the current item which is now mission2 but indexOfTopLevelItem)( current ) returns 1 instead of 0. I think it should be 0 since mission2 is now the only topLevelItem.
Any Idea why this is happening?