zoukankan      html  css  js  c++  java
  • QML遍历查询子元素

    这里要查询一个一个Repeater中嵌套的一个Repeater的Image中的图片是什么. 从而进行属性操作. 要注意的就是普通控件获取children后, 用[]下标即可操作子元素, Repeater要用itemAt函数操作子元素.

    for(var i = 0; i < items; ++i)
    {
        console.log("lineRep["+ i + "] id =      ", lineRep.itemAt(i))      //打印出子控件的类型
        var childItems = lineRep.itemAt(i).children
        console.log("   childitems count : " + childItems.length)
        //第二段是我需要的, 所以这里没有遍历, 直接设置j = 1的. 
        var j = 1
        console.log("   childItems["+ j + "] id =      ", childItems[j])      //打印出子控件的类型
        var grandChidlItems = childItems[j].children
        var childRepC = grandChidlItems[2].count
        console.log("       childRep count = " + childRepC)
        for(var k = 0; k < childRepC; ++k)
        {
            console.log("       childRepson[" + k + "] id = ", grandChidlItems[2].itemAt(k))      //打印出子控件的类型
            var childRepSons = grandChidlItems[2].itemAt(k).children
            console.log("           childRepSons count = ", childRepSons.length)
            for(var l in childRepSons)
            {
                console.log("           childRepSons["+ l + "] id =      ", childRepSons[l])      //打印出子控件的类型
                console.log("               childRepSonsSon[" + l + "] source = ", childRepSons[l].source)      //达到目标, 获取到了图片的名称.
            }
        }
    }
    
  • 相关阅读:
    修改服务器时间及时区
    风情万种awk
    追忆似水流年sed
    lvm笔记
    正则不怎么会用
    在CentOS7.5的虚拟环境下新建你的django项目
    Django学习过程中的排错总结
    我一直记不住的vim用法
    关于自建yum源拾遗
    Djangp2.x版本报错找不到模版目录下的文件
  • 原文地址:https://www.cnblogs.com/linkyip/p/13360857.html
Copyright © 2011-2022 走看看