How to create grouped/nested properties?

后端 未结 3 1855
失恋的感觉
失恋的感觉 2021-01-01 00:57

I am trying to do nested properties like \'font.family\' or \'anchors.fill\', but I cannot initialize them in normal way because it prints \'Cannot assign to non-existent pr

3条回答
  •  無奈伤痛
    2021-01-01 01:21

    Try replacing your nested QtObject with a QML file. For example, I replaced it with BackgroundTheme.qml. This way, the property (which can correcly be called "grouped property") works correctly, in a binding and without any error.

    BackgroundTheme.qml

    import QtQuick 2.0
    
    QtObject {
      property color pressed: "#CCCCCC"
      property color enabled: "#666666"
      property color disabled: "#555555"
    }
    

    MyButtonStyling.qml

    import QtQuick 2.0
    
    QtObject {       
        property BackgroundTheme background: BackgroundTheme {}
    }
    

提交回复
热议问题