zoukankan      html  css  js  c++  java
  • QML 动态创建对象


    创建:
    var xpos = (left_X- width*0.5) var ypos = getY(minPrice) var bshow = false var src2 = 'import QtQuick 2.0;import "qrc:/controls";RT_XdrInfo {x:%1;y:%2;show:false ;dat:%3;}'; src2 = src2.arg((root.canvas._canvas.width -xpos )<120? (root.canvas._canvas.width -130):xpos+ 30).arg(ypos + 30).arg(JSON.stringify(xdr)) var newObject2 = Qt.createQmlObject(src2,root.canvas._canvas, "showxdrInfo"); if (newObject2 === null) { // Error Handling console.log("Error creating object new xdr info Object!"); }else{ var xdrinfodata ={ time:time, obj:newObject2, } xdrInfoarr.push(xdrinfodata) } var src = 'import QtQuick 2.0 ;import "qrc:/controls";Text {id: "flgicon";x: %1;y:%2;font.family: "iconfont";text: String.fromCharCode(0xe65b);color: "#FF0000";font.pixelSize: 24;MouseArea {id: flgArea; parent.width;height: parent.height;anchors.fill: parent ;hoverEnabled: true;onEntered:{onShowInfo(%3,true);} onExited: {onShowInfo(%3,false);}} } ' src = src.arg(xpos).arg(ypos).arg(time.toString()) var newObject = Qt.createQmlObject(src,root.canvas._canvas, "mouseItem"); if (newObject === null) { // Error Handling console.log("Error creating object flg icon!"); }else{ flgxdrarr.push(newObject) } }

    清理:
       if(flgxdrarr.length)
            {
                for(var i=0;i<flgxdrarr.length;i++)
                    flgxdrarr[i].destroy();
            }
            flgxdrarr = []
    
            if(xdrInfoarr.length)
            {
                for(var i=0;i<xdrInfoarr.length;i++)
                    xdrInfoarr[i].obj.destroy();
            }
            xdrInfoarr = []
    
    
    

      

    打赏:

    
    
  • 相关阅读:
    正则表达式常用公式
    造轮子之--Redis
    SqlServer 查询计划分析
    实现poster,json,base64等编码转码工具
    win nginx + php bat启动/停止脚本
    php设计模式——单例模式
    [php]php设计模式 (总结)
    升级openssl 操作记录
    PHP URL安全的Base64位编码
    php curl使用 常用操作
  • 原文地址:https://www.cnblogs.com/blueridge/p/9583971.html
Copyright © 2011-2022 走看看