Send click events to treewidgetitem
This commit is contained in:
parent
f5775422c6
commit
ea51a65dfd
@ -23,6 +23,7 @@ class TreeWidget(QtGui.QTreeWidget):
|
||||
self.setEditTriggers(QtGui.QAbstractItemView.EditKeyPressed|QtGui.QAbstractItemView.SelectedClicked)
|
||||
self.placeholders = []
|
||||
self.childNestingLimit = None
|
||||
self.itemClicked.connect(self._itemClicked)
|
||||
|
||||
def setItemWidget(self, item, col, wid):
|
||||
"""
|
||||
@ -230,7 +231,11 @@ class TreeWidget(QtGui.QTreeWidget):
|
||||
QtGui.QTreeWidget.setColumnCount(self, c)
|
||||
self.sigColumnCountChanged.emit(self, c)
|
||||
|
||||
|
||||
def _itemClicked(self, item, col):
|
||||
if hasattr(item, 'itemClicked'):
|
||||
item.itemClicked(col)
|
||||
|
||||
|
||||
class TreeWidgetItem(QtGui.QTreeWidgetItem):
|
||||
"""
|
||||
TreeWidgetItem that keeps track of its own widgets and expansion state.
|
||||
@ -338,6 +343,12 @@ class TreeWidgetItem(QtGui.QTreeWidgetItem):
|
||||
elif (role in (QtCore.Qt.DisplayRole, QtCore.Qt.EditRole) and text != self.text(column)):
|
||||
treewidget.sigItemTextChanged.emit(self, column)
|
||||
|
||||
def itemClicked(self, col):
|
||||
"""Called when this item is clicked on.
|
||||
|
||||
Override this method to react to user clicks.
|
||||
"""
|
||||
|
||||
|
||||
class InvisibleRootItem(QtGui.QTreeWidgetItem):
|
||||
"""Wrapper around a TreeWidget's invisible root item that calls
|
||||
|
Loading…
x
Reference in New Issue
Block a user