PDA

View Full Version : Blank out line edit contents using EchoMode (?)



dennisvz
12th May 2019, 22:55
I use .setEnabled(False) to disable a line edit so it cannot be used, and it greys out the text inside the line edit. Now, I want to "hide" the greyed out text. I do not want to change the contents of the line edit and I do not want to hide the line edit box. I just want to display an empty box.

If using "EchoMode" is the way to go (it may not be), could someone show me the syntax/example of how to blank out the line edit and then turn it back on to be able to display its contents? Something like (I think):



self.ui.total.setEchoMode(???????)


Added after 22 minutes:

I think I found the answer (appears to do what I want).


self.ui.total.setEchoMode(QLineEdit.NoEcho)


But if someone has a better way, please let me know. thanks for looking

d_stranz
13th May 2019, 16:25
If I were doing this, I would save a copy of the line edit's string in a member variable, set the line edit text to blank, then disable the line edit. When I want to enable it, I would set the text to the saved string, and then enable the line edit again.