屏蔽 QLineEdit 文本 [英] Masking QLineEdit text

查看:38
本文介绍了屏蔽 QLineEdit 文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PyQt4 QLineEdit 小部件来接受密码.有一个 setMasking 属性,但没有遵循如何设置掩码字符.

I am using PyQt4 QLineEdit widget to accept password. There is a setMasking property, but not following how to set the masking character.

推荐答案

在 PyQt4 或 Qt4 中,QLineEdit 没有 setMasking 属性.你是在说 setInputMask() 吗?如果你是,这不会像你认为的那样做.它设置用于验证输入的掩码.

There is no setMasking property for QLineEdit in either PyQt4 or Qt4. Are you talking about setInputMask()? If you are, this does not do what you seem to think it does. It sets the mask against which to validate the input.

要让控件隐藏输入的内容,请使用 setEchoMode() 方法,它将(应该)显示平台的标准密码隐藏字符.从我从文档中可以看出,如果您想要显示自定义字符,则需要派生一个新类.然而,总的来说,这是一个坏主意,因为它与用户期望看到的背道而驰.

To get the control to hide what is typed, use the setEchoMode() method, which will (should) display the standard password hiding character for the platform. From what I can see from the documentation, if you want a custom character to be displayed, you will need to derive a new class. In general however, this is a bad idea, since it goes against what users expect to see.

这篇关于屏蔽 QLineEdit 文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆