-2

Actually some of function of my program stopped when I use asynchronous keyword in loader so is there any alternative of loader or asynchronous in qml?

Aman Kumar
  • 11
  • 3
  • 1
    Please define more about the problem. What stopped working, are there any errors/warnings and how does the code look? – Amfasis Mar 29 '21 at 07:04

1 Answers1

0

Here are 3 example for loading component

//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});
    }



}
Bibin
  • 433
  • 5
  • 12