qml 中是否有加载器的替代方案?
Is there any alternative of loader in qml?
实际上,当我在加载器中使用异步关键字时,我的程序的某些功能停止了,所以在 qml 中是否有加载器或异步的替代方案?
这里有3个加载组件的例子
//1-loading using loader
//2-loading component without loader
//3-loading qml without loader
Window {
id:appWindow
width: 300; height: 100; visible: true
property Component cmpontnt:Rectangle{
width: 10
height: 20
color: "red"
}
Loader{
sourceComponent: cmpontnt//1-- loading through loader
}
Component.onCompleted:{
//2-- loading component using createObject
cmpontnt.createObject(appWindow, {x: 50, y: 50});
//3--creating component from .qml and loading using createObject
var component2 = Qt.createComponent("TestCmp.qml");
component2.createObject(appWindow, {x: 80, y: 50});
}
}
实际上,当我在加载器中使用异步关键字时,我的程序的某些功能停止了,所以在 qml 中是否有加载器或异步的替代方案?
这里有3个加载组件的例子
//1-loading using loader
//2-loading component without loader
//3-loading qml without loader
Window {
id:appWindow
width: 300; height: 100; visible: true
property Component cmpontnt:Rectangle{
width: 10
height: 20
color: "red"
}
Loader{
sourceComponent: cmpontnt//1-- loading through loader
}
Component.onCompleted:{
//2-- loading component using createObject
cmpontnt.createObject(appWindow, {x: 50, y: 50});
//3--creating component from .qml and loading using createObject
var component2 = Qt.createComponent("TestCmp.qml");
component2.createObject(appWindow, {x: 80, y: 50});
}
}