如何在python中清除掩码?我正在使用setInputMask
在qLineEdit
中插入一个掩码,但在一段时间后,我想清除lineEdit
(移除掩码)。我试图使用clearMask
、clear
和setText("")
,但都不起作用
MVCE:
from PyQt5.QtWidgets import QApplication,QLineEdit,QWidget,QFormLayout
from PyQt5.QtGui import QIntValidator,QDoubleValidator,QFont
from PyQt5.QtCore import Qt
import sys
class lineEditDemo(QWidget):
def __init__(self,parent=None):
super().__init__(parent)
e3 = QLineEdit()
e3.setInputMask("+99_9999_999999")
e3.clearMask()
e3.clear()
e3.setText("")
flo = QFormLayout()
flo.addRow("Input Mask",e3)
self.setLayout(flo)
self.setWindowTitle("QLineEdit Example")
if __name__ == "__main__":
app = QApplication(sys.argv)
win = lineEditDemo()
win.show()
sys.exit(app.exec_())
由于clearMask
和其他方法不起作用,我应该使用什么方法来清除lineEdit
掩码
只需使用空字符串:
我强烈建议您阅读文档,而不是尝试随机的事情,因为很明显^{} 与此毫无关系,而^{} 明确指出:
您必须向^{} 传递一个空字符串,正如文档所指出的:
注意:
clearMask()
清除另一种类型的掩码:https://doc.qt.io/qt-5/qwidget.html#setMask相关问题 更多 >
编程相关推荐