Getting data from a QTreeWidgetItem inherited class

1.6k views Asked by At

I have a class which inherits from QTreeWidgetItem and I intercept the click event.

I need to get another object from inside MY QTreeWidgetItem when I click the tree row, how can I do that??

1

There are 1 answers

2
Phil Hannent On BEST ANSWER

You create and add the item:

newItem = new QTreeWidgetItem(myExplorer);

set the data:

newItem->setData(myListWidgetItem::idType, 1234);

And have a slot that accepts the item clicked (on the tree), which you can read the data from:

connect( myExplorer, SIGNAL( itemClicked (QTreeWidgetItem *, int) ), this, SLOT( slotFillListWidget(QTreeWidgetItem *, int) ) );