Qt 在自定义类型的子对象中嵌入子对象

Qt 在自定义类型的子对象中嵌入子对象,qt,qml,qtquick2,qt-quick,Qt,Qml,Qtquick2,Qt Quick,我正在QML中创建一个自定义类型,它在组框中有一个列。当该类型的用户将组件添加到CustomType时,它们应该位于列中,而不是组框。如何在不生成额外包装文件的情况下实现这一点 //CustomType.qml GroupBox { Column { } } //Main.qml CustomType { CheckBox {//This should be inside the Column of the GroupBox in CustomType

我正在QML中创建一个自定义类型,它在
组框中有一个
。当该类型的用户将组件添加到
CustomType
时,它们应该位于
中,而不是
组框
。如何在不生成额外包装文件的情况下实现这一点

//CustomType.qml

GroupBox {
    Column {

    }
}


//Main.qml

CustomType {
    CheckBox {//This should be inside the Column of the GroupBox in CustomType   
    }
}

您可以在
CustomType.qml
中为
GroupBox
的子级创建
属性别名
,并将其声明为
默认
属性,如下所示:

//CustomType.qml

GroupBox {
    default property alias children: body.children

    Column {
        id: body
    }
}

每当您向
CustomType
添加项目时,它们都会进入

您可以为
CustomType.qml
中的
组框
的子级创建
属性别名
,并将其声明为
默认
属性,如下所示:

//CustomType.qml

GroupBox {
    default property alias children: body.children

    Column {
        id: body
    }
}

每当您向
CustomType
添加项目时,它们都会进入

您可以为
CustomType.qml
中的
组框
的子级创建
属性别名
,并将其声明为
默认
属性,如下所示:

//CustomType.qml

GroupBox {
    default property alias children: body.children

    Column {
        id: body
    }
}

每当您向
CustomType
添加项目时,它们都会进入

您可以为
CustomType.qml
中的
组框
的子级创建
属性别名
,并将其声明为
默认
属性,如下所示:

//CustomType.qml

GroupBox {
    default property alias children: body.children

    Column {
        id: body
    }
}
每当您将项目添加到
自定义类型
,它们都会进入