Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Password input on a treewidgetitem
dnlhoust last edited by
Hello all (and happy christmas/holidays!)
To the point: How do I get a QTreeWidgetItem to respect a QLineEdits setEchoMode(QLineEdit.Password) ?
I've been banging my head against the wall for this for the last day:
I have a subclass of QTreeWidgetItem (which simply adds one extra field to the class)
I create an instance of it, add it to my TreeWidget:
twi = DIMTreeWidgetItem.DIMTreeWidgetItem(uuid.uuid4(), [field_name, '<Empty>']) ... self.ui_instance.main_window.treeWidget.addTopLevelItem(twi)
I edit that an instance based on a double click of that item with:
This works fine.
I have a delegate attached to that column which is simply:
def __init__(self, parent=None, *args): QStyledItemDelegate.__init__(self, parent, *args) def createEditor(self, parent, option, index): le = QLineEdit('', parent) le.setEchoMode(QLineEdit.PasswordEchoOnEdit) return le
But it seems this only effects the item during editing. What is the correct way for me to obscure the content of the treewidgetitem after editing?
-KRS- last edited by
I haven't done this myself, but I'm guessing you need to override QStyledItemDelegate's paint() method as well. So something like they've done here.
VRonin last edited by
This question is identical to https://forum.qt.io/topic/97835/custom-qtablewidgetitem
You just need to translate the C++ code of the solution to python, should be easy