How to create grouped/nested properties?

后端 未结 3 1867
失恋的感觉
失恋的感觉 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:01

    This may not be the right way. But this works

    MyButtonStyling.qml

    import QtQml 2.1
    
    QtObject
    {
        property alias background: _obj_background
    
        QtObject 
        {
            id: _obj_background
            property color pressed: "#CCCCCC"
            property color enabled: "#666666"
            property color disabled: "#555555"
        }
    }
    

    Now using background.enabled: "#1B2E0A" in main.qml works.

提交回复
热议问题