Getting currentIndex from Selected item in QtreeWidget
I have a QtreeWidget build with designer with three items.
I want to execute a function when each item is selected, i can connect the signal itemclicked to a function, then what can i use to do a switch case?
Ive tried qtreewidgetitem, but no luck...
I setup the Signal/slot so that is calls a function...
Code:
this, SLOT(setActiveTool());
int Porcupine::setActiveTool()
{
// What goes here to determine the current index of the selected tree item?
switch (item) {
case 0:
{
ui.pageTitle->setText("case 0");
}
break;
case 1:
{
ui.pageTitle->setText("case 1");
}
break;
case 2:
{
ui.pageTitle->setText("case 2");
}
break;
}
}
Re: Getting currentIndex from Selected item in QtreeWidget
How about using indexOfTopLevelItem to get the index ?
Re: Getting currentIndex from Selected item in QtreeWidget
The signal carries a pointer to the item. Make your slot accept it as an argument and use it.