在PySide6中尝试使用true_property
和/或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
和/或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
这是一个bug,还是我遗漏了什么?
我真的必须在这些符合人体工程学的Python和方便的构造函数之间做出选择吗?还是有办法让它们协同工作?
是什么导致了这种行为?
这确实是PySide中的一个错误,我在这里报告了它:PySide-1705。
从PySide 6.2.4开始,它已被修复。