Using QtCore.Property as a decorator marks all properties writable, even if no setter is defined.
from PySide6.QtCore import QObject, Property class A(QObject): @Property(int) def x(self): return 10
A().metaObject() yields
PySide6.QtCore.QMetaObject("A" inherits "QObject":
Properties:
#1 "x", int [writeable] [resettable] [designable]
)
A().metaObject().property(0).isWritable() is True
Calling Property explicitly works,
class B(QObject): def _x(self): return 10 x = Property(int, _x)
B().metaObject() yields
PySide6.QtCore.QMetaObject("B" inherits "QObject":
Properties:
#1 "x", int [designable]
)
B().metaObject().property(0).isWritable() is False
However, explicitly setting fset=None doesn't work,
class C(QObject): def _x(self): return 10 x = Property(int, _x, None)
C().metaObject() yields
PySide6.QtCore.QMetaObject("C" inherits "QObject":
Properties:
#1 "x", int [writeable] [designable]
)
C().metaObject().property(0).isWritable() is True
Also, only for B the proper AttributeError is raised when trying to write the property. In the other cases it is TypeError: 'NoneType' object is not callable.
The same problem likely exists for reset.
- relates to
-
PYSIDE-924 Declaring a (Q)Property as "constant" does not work
-
- Closed
-
| For Gerrit Dashboard: PYSIDE-3227 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 688306,19 | WIP: PySide6/Property: Use a capsule for copying properties | dev | pyside/pyside-setup | Status: NEW | -2 | +1 |
| 688394,8 | libpyside/libpysideqml: Refactor property argument parsing | dev | pyside/pyside-setup | Status: NEW | 0 | 0 |
| 688431,10 | libpyside/libpysideqml: Introduce flags for property arguments | dev | pyside/pyside-setup | Status: NEW | 0 | +1 |
| 688637,5 | WIP: libpyside/libpysideqml: Introduce base class for the properties | dev | pyside/pyside-setup | Status: NEW | -2 | 0 |
| 688269,6 | PySide6/Property: Fix read-only properties when using the decorator syntax | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 688363,2 | PySide6/Property: Fix read-only properties when using the decorator syntax | 6.10 | pyside/pyside-setup | Status: MERGED | +2 | 0 |