Hi. Was about to post the code but had a final hack at it first and I *think* I see the problem (i.e. the hole into which I was falling!) It's probably worth mentioning, and I'd appreciate if anyone could confirm that I've got it right too.
My wrong version had me doing the following (pythonish pseudo-code):
iterq = QListViewItemIterator(xxxxxxxxx)
while iterq.current():
item = iterq.current()
if <some arbitrary condition>
listView.takeItem( item)
newparentItem.insertItem( item )
iterq += 1 # Bump the incrementor
iterq = QListViewItemIterator(xxxxxxxxx)
while iterq.current():
item = iterq.current()
if <some arbitrary condition>
listView.takeItem( item)
newparentItem.insertItem( item )
iterq += 1 # Bump the incrementor
To copy to clipboard, switch view to plain text mode
The problem seems to be down to me double-incrementing iterq unwittingly! When the condition is true, it seems like when I do the takeItem the iterq is AUTOMATICALLY incremented. Which does make sense when I think about it, but is a point I had missed.
So the fix to my problem is really easy: when I go through the takeItem/insertItem section I explicitly avoid doing the iterq += 1 and simply (in Python) "continue" back at the while - knowing iterq has already been bumped.
The fixed version just has the one extra line:
iterq = QListViewItemIterator(xxxxxxxxx)
while iterq.current():
item = iterq.current()
if <some arbitrary condition>
listView.takeItem( item)
newparentItem.insertItem( item )
continue #<-------******* ADDED! *****
iterq += 1 # Bump the incrementor
iterq = QListViewItemIterator(xxxxxxxxx)
while iterq.current():
item = iterq.current()
if <some arbitrary condition>
listView.takeItem( item)
newparentItem.insertItem( item )
continue #<-------******* ADDED! *****
iterq += 1 # Bump the incrementor
To copy to clipboard, switch view to plain text mode
Hope this might help some other newbie some day!
Sean
Bookmarks