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??

Wooble
  • 87,717
  • 12
  • 108
  • 131
JuanDeLosMuertos
  • 4,532
  • 15
  • 55
  • 87

1 Answers1

1

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
  • 12,047
  • 17
  • 71
  • 118
  • 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 Dec 09 '08 at 15:52
  • 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) – JuanDeLosMuertos Dec 09 '08 at 17:38