Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-89655

Add support for custom getters and setters in QProperty

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.0.0
    • Core: Object Model
    • None
    • 55
    • Team 1 Foundation_Sprint 42, Team 1 Foundation_Sprint 43

      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

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            fabiankosmale Fabian Kosmale
            ivan.solovev Ivan Solovev
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes