Property 1、Property1.1 定义控件1.2 给控件取别名,不向外暴露控件名字 2、总结 1、Property property int myTopMargin: 0 property int myBottomMargin: 0 property real myReal: 0.0 //双精度浮点数 property string myString: "test" property color myColor: "black" property Component myComponent 1.1 定义控件 property Component myComponent Loader{ id:loader sourceComponent: myComponent } Component{ id:com Button{ width: 50 height: 50 } } MyRectangle{ myComponent:com myTopMargin:10 } 1.2 给控件取别名,不向外暴露控件名字 property alias newInerRecColor: innerRect.color //取别名 MyRectangle{ myComponent:com myTopMargin:10 Component.onCompleted: { newInerRecColor = "yellow" } } 2、总结 以上就是C++的一些基础知识了,浏览过程中,如若发现错误,欢迎大家指正,有问题的欢迎评论区留言或者私信。最后,如果大家觉得有所帮助,可以点一下赞,谢谢大家!祝大家天天开心,顺遂无虞!