Detect ONLY when a QTreeWidgetItem text has been edited.
Hello,
I've been searching the forum but didn't find any clue about the following doubt:
I have a QTreeWidgetItem that I have made it editable:
Code:
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
If I use:
Code:
connect(tree
->treeWidget,
SIGNAL(itemChanged
( QTreeWidgetItem *,
int)),
(Tree
*)tree,
SLOT(foo
()))
it detects not only when it has been edited, but also if its icon has changed.
1) Is there an easy way to detect only when its text has been changed?
2) The connect code that I use detects changes in any item of the tree. How can I make it to trigger only for a certain Item of the tree?
Thank you in advance,
Re: Detect ONLY when a QTreeWidgetItem text has been edited.
Quote:
1) Is there an easy way to detect only when its text has been changed?
2) The connect code that I use detects changes in any item of the tree. How can I make it to trigger only for a certain Item of the tree?
Add parameters to slot foo() and inside the slot function check for the item and role
Re: Detect ONLY when a QTreeWidgetItem text has been edited.
Thanks for you answer,
and how could I detect only when its text has been changed? Not a setIcon or something like that.
Re: Detect ONLY when a QTreeWidgetItem text has been edited.
when role == Qt::DisplayRole
Re: Detect ONLY when a QTreeWidgetItem text has been edited.
I dont use any model. Can I use a role in my case?
Re: Detect ONLY when a QTreeWidgetItem text has been edited.
Oops, sorry my mistake.
When using QTreeWidget it will not be possible. Any change will trigger the signal, filtering for text change is not possible.