PDA

View Full Version : current index of the sleected item in QTreeWidget



wagmare
11th August 2010, 10:46
hi friends,
can u please help me how i can get the currentindex value as integer of the selected item in QTreeWidget ...

i manage to get the data but the currentIndex() at present returning QmodelIndex() . not able to convert it to integer ..


can any one please help me ...

Lykurg
11th August 2010, 11:45
to what integer? Row or column? E.g.
currentIndex().row()

wagmare
11th August 2010, 12:39
thanks for reply ...

i have attached my QTreeWidgets screenshot with this thread ...

here if the user selects CIM_ComputerSystems or first child of CIM_System and clicked some pushButton .. how can i identify it in my pushButton slot xx() the item selected ... by its index number or some other way ...

i tried like this
cout<<_treeView->currentIndex().row()<<endl;

it all showing 0 as constant...

but i am manage to get the string of the QTreeWidget Item..

please help ...

Lykurg
11th August 2010, 13:47
It is returning always 0 because it is relative to its parent. If you want unique identification you have to set a uuid to the items yourself using the Qt::UserRole role. (Or create a "integer path" back to the root item)