Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.0.0
-
None
-
55
-
Team 1 Foundation_Sprint 42, Team 1 Foundation_Sprint 43
Description
If I understand correctly, currently QProperty allows only trivial getters and setters.
Custom getters can be achieved by reimplementing QBindableInterface's getter() and makeBinding() methods. However this approach is quite verbose (see example here: https://codereview.qt-project.org/c/qt/qtbase/+/327038/6/src/corelib/itemmodels/qabstractproxymodel_p.h).
The situation with setters is even worse. We do have a Q_OBJECT_COMPAT_PROPERTY macro, that allows a custom setter, but if we just want to use QProperty, there is no way for now. Trying to achieve that, I had to create my own class, which was a combination of QProperty and QObjectCompatProperty: https://codereview.qt-project.org/c/qt/qtbase/+/327265/3/src/corelib/kernel/qcoreapplication_p.h
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-89655 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
372559,9 | QObjectCompatProperty: Add support for custom getters | dev | qt/qtbase | Status: MERGED | +2 | 0 |
372560,7 | QAbstractProxyModel: Use QCompatProperty with custom getter | dev | qt/qtbase | Status: MERGED | +2 | 0 |