Home > other >  How to get the QTreeWidgetItem ID
How to get the QTreeWidgetItem ID

Time:10-14

I want to click on different items in the QTreeWidget, pop-up a different dialog box, the connect function is as follows: connect (this, SIGNAL (itemClicked (QTreeWidgetItem *, int)), and this, SLOT (myfunction (QTreeWidgetItem *, int))); In myfunction (QTreeWidgetItem *, int), how to get the ID of the QTreeWidgetItem, so that to distinguish different QTreeWidgetItem?

CodePudding user response:

Void itemClicked (QTreeWidgetItem * item, int column), the signal of the second argument, is the number of columns of this item. What is his columns. Distinguish between just the way they are.

CodePudding user response:

Thank you for your reply but my QTreeWidget upstairs is used to display the tree menu, the number of columns column only one want to ask how to distinguish between different lines with QTreeWidgetItem

CodePudding user response:

QTreeWidgetitem * clickedItem=qobject_case & lt; QTreeWidgetItem * & gt; (sender ()); This should be able to get click on the item

CodePudding user response:

Problem has been solved, such as the upstairs said, through the QTreeWidgetitem * can differentiate different QTreeWidgetitem thanks for your reply

CodePudding user response:

QTreeWidgetitem not a qobject should use qobject_cast

CodePudding user response:

QTreeWidgetItem * clickedItem=qobject_case & lt; QTreeWidgetItem * & gt; (sender ()); 1 & gt; ./Control/TreeList. CPP (105) : error C2065: 'qobject_case: undeclared identifier1 & gt; ./Control/TreeList. CPP (105) : error C2059: syntax error: '& gt; '

CodePudding user response:

reference 4 floor response:
problem has been solved, such as the upstairs said, through the QTreeWidgetitem * can distinguish different QTreeWidgetitem thanks for your reply

But it also get id? Seem to only get the text
  • Related