我已将属性设置为 QLineEdit 为
self.ui.txtName.setProperty('rules', 'required')
我想动态删除这个属性,有什么办法吗,
最佳答案
Docs说:
...
A property can be removed from an instance by passing the property name and an invalid QVariant value to QObject::setProperty(). The default constructor for QVariant constructs an invalid QVariant.
这适用于 PyQt:
self.ui.txtName.setProperty("rules", QtCore.QVariant())
#or
self.ui.txtName.setProperty("rules", None)
关于python - 如何删除 pyside/pyqt 中 ui 组件的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9653264/