Is it possible to put a QLineEdit() into a QTreeWidgetItem() in order to modify the text of the QTreeWidgetItem ?
Here is my code
def addItemsToTree(self, parent, text, checkable=False, expanded=True):
self.item = QTreeWidgetItem(parent, [text])
if checkable:
self.item.setCheckState(0, Qt.Unchecked)
else:
self.item.setFlags(self.item.flags() & ~Qt.ItemIsUserCheckable)
self.item.setExpanded(expanded)
min = QLineEdit()
max = QLineEdit()
self.addChildTree(self.item, self.column, "Min =", "Min =")
self.addChildTree(self.item, self.column, "Max =", "Max =")
return self.item
def addChildTree(self, parent, column, title, data):
item = QTreeWidgetItem(parent, [title])
item.setData(column, Qt.UserRole, data)
return item
It should suffice to set your item flags to include
ItemIsEditable
:You can also configure the EditTriggers to start editing as you like, e.g. upon double-clicking an item:
Double-clicking an item in your treewidget should now bring up an editor - which by default is simply a
QLineEdit
.