true_property 和 snake_case 破坏了 PySide6 中的 属性-关键字小部件构造函数

true_property and snake_case breaking property-keyword widget constructors in PySide6

我在 PySide6 中尝试使用 true_property and/or snake_case 时遇到问题。没有任何一个,我可以使用这样的形式构建小部件:

text = QtWidgets.QLabel('Example', margin=10)

我在创建小部件时将 Qt 属性指定为关键字参数。这与以下内容相同:

text = QtWidgets.QLabel('Example', margin=10)
text.setMargin(10)
# Or with snake_case:
text.set_margin(10)
# Or with true_property:
text.margin = 10

但是,导入 snake_case and/or true_property 会破坏此“快捷方式”构造函数。我得到以下结果:

from PySide6 import QtWidgets
from __feature__ import snake_case

app = QtWidgets.QApplication()
text = QtWidgets.QLabel('Example', margin=10)

# AttributeError: PySide6.QtWidgets.QLabel.__init__(): 'margin' is not a Qt property or a signal
from PySide6 import QtWidgets
from __feature__ import true_property
# Same results from either of these:
# from __feature__ import snake_case, true_property
# from __feature__ import true_property, snake_case

app = QtWidgets.QApplication()
text = QtWidgets.QLabel('Example', margin=10)

# Segmentation fault: 11

这是一个错误,还是我遗漏了什么?

我真的必须在这些符合人体工程学的 Python 化和方便的构造函数之间做出选择,还是有办法让它们一起工作?

是什么导致了这种行为?

这确实是 PySide 中的一个错误,我在这里报告过:PYSIDE-1705

从 PySide 6.2.4 开始,该问题现已得到修复。