在使用Loader来加载定义的一个独立的组件的时候,可以使用Loader的source来进行加载。
具体源码如下:
import QtQuick 2.2
Rectangle{
width: 320;
height: 240;
color:"#eeeeee";
Text{
id:coloredText;
anchors.horizontalCenter: parent.horizontalCenter;
anchors.top: parent.top;
anchors.topMargin: 4;
text:"Hello World!";
font.pixelSize: 32;
}
Component{
id: colorComponent;
Rectangle{
id: colorPicker;
width: 50</