You might do it this way (it's just a concept):

Qt Code:
  1. QPtrList<QListViewItem> _items;
  2. myItem *item = dynamic_cast<myItem>(this->firstChild());
  3. while(item){
  4. if(item->myBoolFunction()) _items.push_back(item);
  5. item = dynamic_cast<myItem>(item->nextSibling());
  6. }
  7. for(QPtrList<QListViewItem>::iterator it = _items.begin(); it!=_items.end();++it){
  8. takeItem(*it);
  9. insertItem(*it); // or some other method like moveItem()
  10. }
To copy to clipboard, switch view to plain text mode 

The first iteration looks for all items to move upwards, the second does the move.