How do I change the password field to show "******" in table widget
-
Hi,
I am trying to show user name and password in table widget that table is editable, so while giving input for password, I want to change string as "*******" it's possible to do.
-
-
@koahnig
QTableWidget for editable row, While giving input I am trying to give string as *****@yashi95
I don't know/think that you can change aQTableWidget's editor to what you want. You can for aQTableView, as per this old post from 2007 (! still valid) https://www.qtcentre.org/threads/7678-QTableWidget-editItem-how-to-get-pointer-to-the-editor?p=41223#post41223:You cannot obtain it from a QTableWidget.
Use a QTableView instead and create the editor with the default item delegate, using:
QAbstractItemView::itemDelegate and QAbstractItemDelegate::createEditor.
The latter will also return a pointer to the editor.
Then you can have your own
QLineEdit, withEchoMode.Having said that: simpler would be using the approach in https://stackoverflow.com/questions/11056245/pyqt-using-qlineedit-as-cellwidget-in-a-qtablewidget, i.e.
setCellWidget(QLineEdit()), if you don't want to do it "properly" with an item delegate. It will then stay as aQLineEditeven when not being edited, I don't know if you care. -
Hi,
I would go with a custom QStyledItemDelegate that provides a QLineEdit with the adequate echo mode.
Note that from a security point of view, the password shall be immediately encrypted and not stored as is.