Where are the signals itemChecked and itemUncheсked on the QTreeWidget?
Qt Signals: (quote from PyQt4 QTreeWidget documentation page)
void currentItemChanged (QTreeWidgetItem *,QTreeWidgetItem *)
void itemActivated (QTreeWidgetItem *,int)
void itemChanged (QTreeWidgetItem *,int)
void itemClicked (QTreeWidgetItem *,int)
void itemCollapsed (QTreeWidgetItem *)
void itemDoubleClicked (QTreeWidgetItem *,int)
void itemEntered (QTreeWidgetItem *,int)
void itemExpanded (QTreeWidgetItem *)
void itemPressed (QTreeWidgetItem *,int)
void itemSelectionChanged ()
At current moment I solved it like this:
self.treeWidget.itemClicked.connect (self.handle)
def handle (item, column):
print 'emitted!', item.text(column)
if item.checkState(column) == QtCore.Qt.Checked:
# there are a lot of my functions inside which work with item data
self.handleChecked(item, column)
elif item.checkState(column) == QtCore.Qt.Unchecked:
self.handleUnchecked(item, column)
But it's a bad solution for me, because itemClicked emitted in a really lot of cases. It emitted in the case of Left/Right Mouse Clicks on the item text, which is absolutely unnecessary (I have heavy functions within self.handleChecked, and unnecessary calls of them on the context menu opening are pretty lousy).
Well, I also tried to use itemChanged:
self.treeWidget.itemChanged.connect (self.handle)
but this way situation is even worse! self.handle function calls himself recursively to infinity and beyond, because my functions within self.handleChecked change item data and this signal emits again and again. Also, I need signal which emits only on item checkbox toggling.
Can someone tell me, what I'm doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…