Use QTreeWidgetItemIterator for iterate over the items. Details and example of using: http://qt-project.org/doc/qt-4.8/qtreewidgetitemiterator.html
Inside the loop, you can choose your actions, depending on the property isSelected
(*it)->isSelected()