Reputation: 6147
How can I add an additional function to take place when an item is expanded? Below I've attempted to re-implement the expandItem event but it doesn't appear to do anything. Why is that?
# QTreeWidgets
# ------------------------------------------------------------------------------
class FactionsTreeWidget( QtGui.QTreeWidget ):
def __init__(self, parent=None):
QtGui.QTreeWidget.__init__(self, parent)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.setItemsExpandable(True)
self.setAlternatingRowColors(True)
def itemExpanded( self, *args, **kwargs ):
res = super( self, my_class ).itemExpanded( *args, **kwargs )
print "expanding stuff..."
return res
Upvotes: 1
Views: 62
Reputation: 6065
itemExpanded
is a signal emitted by QTreeWidget
, not one of it's method.
So you just need to connect this signal to your function.
...
self.itemExpanded.connect(self.onItemExpanded)
def onItemExpanded(self,item):
print("stuff")
Upvotes: 2