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

[SOLVED] How to define default property of type list in qml



  • Hi,
    I'm trying to create a custom default property for an Item which should act like the children default property, but only accepting my custom types.

    E.g. this is how I would like the QML item to be used:
    @MyComponent {
    MyItem { }
    MyItem { }
    MyItem { }
    }@

    Therefore I tried to set the following default property definition in MyComponent:
    @default property list <MyItem> myChildren@

    But this results in errors:
    "Unexpected token '<'" and "Expected token ':'"

    How to do that with Qt 5?

    Thanks,
    Chris



  • see https://bugreports.qt-project.org/browse/QTBUG-10822

    you can try,

    @
    id: root
    property list <MyItem> myChildren
    default property alias children: root.myChildren
    @

    Do you test your code in Qt 5.3?


Log in to reply