views:

562

answers:

1

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  A: 

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) ) );
Phil Hannent
Initially I assumed that you would intercept the signal from the Tree Item, however after further reading I see that getting the trees clicked signal is what you really need.
Phil Hannent
ok, I can put my data but I can't read it because it becomes a QVariant data. How can I cast from QVariant to Pkg? (Pkg is the object that I put into the treewidgetitem)
Giancarlo