PDA

View Full Version : Iteration problem



Pharell
1st October 2007, 10:49
Hi
I have a Qlistview which has items in it. Each item has its children like:
a
b
c
d
d1
d2
e

d has for example two children. My problem is that when i want to select the item d
that its children should also be selected. Here comes my code:


QListViewItemIterator it(mylistview, QListViewItemIterator::Selected);
while( it.current())
{
MyClass * p1 = ((MyListViewItem*)it.current())->getP1();
MyClass * p2 = ((MyListViewItem*)it.current())->getP2();
if ( p1 )
{
// code
}
if ( p2 )
// code

it++;
}

Can someone please direct me how to select the children of the items in above situation?
Regards,

wysota
1st October 2007, 10:56
You should do it by using a recursive method, especially that children might have children as well...