PDA

View Full Version : when click the text of QTreeWidgetItem,let it no reaction



weixj2003ld
13th March 2012, 02:22
I create a tree with

and add signal and slots to it with the following code:


connect(tree,SIGNAL(itemPressed(QTreeWidgetItem *, int)), this,SLOT(SlotItemClicked(QTreeWidgetItem *, int)));

I create a tree item of it with QTreeWidgetItem,and set it checked with setCheckState(0,Qt::Checked);
When I don't click checkbox of the tree item but the text of it,I find that it still has reaction,that is,the slot SlotItemClicked() still executes,but the check state of the tree item does not change.
Now I want to it reacts only the checkbox of the tree item is clicked.
How to do it?

weixj2003ld
14th March 2012, 08:29
Is there no help?

ChrisW67
14th March 2012, 08:59
Look for the check box state change rather than a click on the visual. The "itemChanged(QTreeWidgetItem*, int)" signal from the QTreeView might be a good place to start.

weixj2003ld
16th March 2012, 04:22
There are checkable items and uncheckable items in my tree, If I use "itemChanged(QTreeWidgetItem*, int)" ,I find that there is no respones when I click an uncheckable item(for its state does not change ).

How to confirm the state of an checkable item changes or not when click it?