How to load a component from qml file in loader
-
Hi,
I have component definition in a.qml. I want to load this component in main.qml.
code snippet:
a.qml:
Component {
id: testa
Rectangle {
width: 100
height: 60
color: 'red'
}
}main.qml:
Loader {
sourceComponent: testa
}It's throwing error saying reference error. Tried with source:"a.qml". I am doing something wrong.
Any idea?
Thanks.
-
Hi,
If you are using different file use source instead of sourceComponent and set it to QML file.
-
Try removing the Component from a.qml. Just keep the Rectangle.