python - 如何删除 pyside/pyqt 中 ui 组件的属性?

标签 python pyqt pyside

我已将属性设置为 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/

相关文章:

python - PySide 子线程中的计时器

qt - 在 QTreeView 中用鼠标悬停突出显示项目?

python - 为什么 Pandas 提示 'n' 是 split 函数的无效关键字参数?

python - 我如何转换 .在PyQt5的QLineEdit中输入0.?

python - 如何使用 pandas read_pickle 从 qrc 资源文件中读取包含 pandas 数据框的 pickle 文件?

python - 在子类对话框窗口中使用方法影响主窗口时出现问题

Python 控制台网站

python - 从日期选择器获取可用性

python - 看不懂这个定时while循环属性报错

python - 在 PySide2 中设置垂直和水平对齐方式