Password input on a treewidgetitem

  • 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>'])

    I edit that an instance based on a double click of that item with:

    self.ui_instance.main_window.treeWidget.editItem(item, column)

    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)
            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?

  • 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.

  • This question is identical to
    You just need to translate the C++ code of the solution to python, should be easy

Log in to reply