Unsolved [SOLVED] How to get selected item on QTreeView ?
-
How to get selected item on QTreeView ?
-
-
currentIndex() doesn't work?
-
Please give me example code
-
Hi @takoo ,
connect(treeWidgetName, SIGNAL(itemSelectionChanged()), this, SLOT(mySlot_Changed()));or
connect(this,SIGNAL(itemClicked(QTreeWidgetItem*, int)), SLOT((mySlot_Changed()));
http://doc.qt.io/qt-4.8/qtreewidget.html#itemSelectionChanged
-
@takoo
Hello,
As @asanka424 suggested, use the available API for the view and the model:QTreeView * view; //< You have that properly set, I'm putting it here for completeness. QModelIndex index = view->currentIndex(); QVariant data = view->model()->data(index); QString text = data.toString();
Kind regards.
-
If you want to get the item use QModelIndex::internalPointer()
-
@kshegunov thanks :D
-
This post is deleted!