Results 1 to 4 of 4

Thread: what's wrong with my setEchoMode code

  1. #1
    Join Date
    Jan 2013
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question what's wrong with my setEchoMode code

    I create a QLineEdit in PyQt, and i want to hide or show the charactor of password, so i use the code below
    Here is my login_ui py file login.py, you can use it to test my code within the py or import it from other py.
    Qt Code:
    1. #in the init function, ck_pwd and ck_pay_pwd are QCheckBox, password and pay_password are QLineEdit
    2. def init(self):
    3. QtCore.QObject.connect(self.login_ui.ck_pwd, QtCore.SIGNAL("stateChanged(int)"), lambda : self.show_or_hide_pass(self.login_ui.password))
    4. QtCore.QObject.connect(self.login_ui.ck_pay_pwd, QtCore.SIGNAL("stateChanged(int)"), lambda : self.show_or_hide_pass(self.login_ui.pay_password))
    5.  
    6.  
    7. def show_or_hide_pass(self, password_obj):
    8. if password_obj.EchoMode()!=QtGui.QLineEdit.Normal:
    9. print 'normal'
    10. password_obj.setEchoMode(QtGui.QLineEdit.Normal)
    11. else:
    12. print 'password'
    13. password_obj.setEchoMode(QtGui.QLineEdit.Password)
    To copy to clipboard, switch view to plain text mode 

    but in the function show_or_hide_pass, the password_obj.EchoMode() always be the 0 (value of QtGui.QLineEdit.Normal), it doesn't make any sense.
    what's wrong with my code, Is there somebody can help?
    Last edited by catchxiaoshuang; 13th June 2015 at 06:15.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,554
    Thanks
    13
    Thanked 1,581 Times in 1,510 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: what's wrong with my setEchoMode code

    Line 8, the property name is echoMode() not EchoMode().

  3. The following user says thank you to ChrisW67 for this useful post:

    catchxiaoshuang (13th June 2015)

  4. #3
    Join Date
    Jan 2013
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: what's wrong with my setEchoMode code

    oh, what a fuck!!
    that is the problem.
    thanks a lot

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,554
    Thanks
    13
    Thanked 1,581 Times in 1,510 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: what's wrong with my setEchoMode code

    Perhaps PyChecker or Pylint would have flagged this for you.

Similar Threads

  1. Replies: 3
    Last Post: 18th May 2015, 09:03
  2. Is this bug or wrong code for PyQt4?
    By Rictrunks in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2014, 11:55
  3. What's wrong with my code?
    By Dave2011 in forum Newbie
    Replies: 4
    Last Post: 12th August 2011, 23:35
  4. What is wrong with this code?
    By Jeffb in forum Newbie
    Replies: 6
    Last Post: 18th February 2011, 08:35
  5. What is wrong with my code?
    By Dante in forum Qt Programming
    Replies: 27
    Last Post: 6th April 2009, 08:56

Tags for this Thread

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.