微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

qml 中是否有加载器的替代品?

如何解决qml 中是否有加载器的替代品?

实际上,当我在 loader 中使用 asynchronous 关键字时,我的程序的某些功能停止了,那么在 qml 中是否有 loader 或 asynchronous 的替代方案?

解决方法

这里有 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});
    }



}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。