Results 1 to 2 of 2

Thread: Blank out line edit contents using EchoMode (?)

  1. #1
    Join Date
    Jan 2017
    Posts
    33
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Blank out line edit contents using EchoMode (?)

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

    Qt Code:
    1. self.ui.total.setEchoMode(???????)
    To copy to clipboard, switch view to plain text mode 


    Added after 22 minutes:


    I think I found the answer (appears to do what I want).
    Qt Code:
    1. self.ui.total.setEchoMode(QLineEdit.NoEcho)
    To copy to clipboard, switch view to plain text mode 

    But if someone has a better way, please let me know. thanks for looking
    Last edited by dennisvz; 12th May 2019 at 23:55.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,194
    Thanks
    237
    Thanked 668 Times in 658 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Blank out line edit contents using EchoMode (?)

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 20:06
  2. validator on line edit
    By Raul in forum Qt Programming
    Replies: 4
    Last Post: 27th August 2010, 05:18
  3. Replies: 3
    Last Post: 26th August 2010, 09:57
  4. mask line edit
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 3rd July 2007, 11:27
  5. Replies: 8
    Last Post: 15th May 2007, 10:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.