[SOLVED] How to get selected item on QTreeView ?
Unsolved
General and Desktop
-
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.
-
@kshegunov thanks :D