Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Password input on a treewidgetitem
Forum Updated to NodeBB v4.3 + New Features

Password input on a treewidgetitem

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 926 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dnlhoust
    wrote on last edited by
    #1

    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:

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

    1 Reply Last reply
    0
    • - Offline
      - Offline
      -KRS-
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        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

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved