Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt6/QML override final property



  • Greetings,

    There's the following in QuickWindow:

    class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus
    {
        Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged BINDABLE bindableX FINAL)
    

    And the following in my class:

    class QuickWindow : public QuickItem
    {
        Q_PROPERTY(int X READ x WRITE setX NOTIFY xChanged)
    

    And I do get the this at runtime:

    Final member x is overridden in class QuickWindow. The override won't be used.
    

    In Qt6, is there a way to override a final property like FINAL OVERRIDE ?


  • Lifetime Qt Champion

    Hi,

    No, that's the goal of final.

    The real question here is why are you using the same property name for something that returns a different type ?

    The return type is not part of a method signature so in any case the getter cannot be "overridden".


Log in to reply