[SOLVED]about get the Index of the SelectedItem on the QTreeWidget
-
If only one item is selected, I think yes, because setting current item also selects it.
Well, I think you will get problems when having more than one selected item. I think the only way to handle with that is using selectedItems and IndexFromItem:
@QTreeWidget* treewidget;// some code...
QList<QTreeWidgetItem*> items_selected = treewidget->selectedItems();
QList<QModelIndex*> indexes_selected;
for(int i = 0; i < items_selected.count(); i++)
indexes_selected.append(treewidget->indexFromItem(items_selected.at(i)));@
(not tested)or directly using:
@treewidget->selectedIndexes():@
I would also use this method if only one item is selected, you can check that with items_selected.count() if you need this information later. currentItem() is no good way for multi-selections I think.Hope that helps you...