lqml/examples/cl-repl/qml/ext/Dynamic.qml
2022-12-06 14:39:19 +01:00

23 lines
518 B
QML

import QtQuick 2.15
Item {
objectName: "dynamic"
property Component component
property Item item
function createItem(file) {
// for custom QML items to be loaded on top of REPL app
if (item != null) {
item.destroy()
}
Engine.clearCache()
var pre = (Qt.platform.os === "windows") ? "file:/" : "file://"
component = Qt.createComponent(pre + file)
if (component.status === Component.Ready) {
item = component.createObject()
return item
}
return null
}
}