zoukankan      html  css  js  c++  java
  • qml实现折叠框

    Item{

    width:200
    height:300
    ListView{
    anchors.fill:parent
    model:nestedModel
    delegate:categoryDelegate
    }
    ListModel{
    id:nestedModel
    ListElement{
    categoryName:"Veggies"
    collapsed:true
    //AListElementcan'tcontainchildelements,butitcancontain
    //alistofelements.AlistofListElementscanbeusedasamodel
    //justlikeanyothermodeltype.
    subItems:[
    ListElement{itemName:"Tomato"},
    ListElement{itemName:"Tomato"},
    ListElement{itemName:"Tomato"},
    ListElement{itemName:"Cucumber"},
    ListElement{itemName:"Onion"},
    ListElement{itemName:"Brains"}
    ]
    }
    ListElement{
    categoryName:"Fruits"
    collapsed:true
    subItems:[
    ListElement{itemName:"Orange"},
    ListElement{itemName:"Apple"},
    ListElement{itemName:"Pear"},
    ListElement{itemName:"Lemon"}
    ]
    }
    ListElement{
    categoryName:"Cars"
    collapsed:true
    subItems:[
    ListElement{itemName:"Nissan"},
    ListElement{itemName:"Toyota"},
    ListElement{itemName:"Chevy"},
    ListElement{itemName:"Audi"}
    ]
    }
    }
    Component{
    id:categoryDelegate
    Column{
    width:200
    Rectangle{
    id:categoryItem
    border.color:"black"
    border.width:5
    color:"white"
    height:50
    width:200
    Text{
    anchors.verticalCenter:parent.verticalCenter
    x:15
    font.pixelSize:24
    text:categoryName
    }
    Rectangle{
    color:"red"
    width:30
    height:30
    anchors.right:parent.right
    anchors.rightMargin:15
    anchors.verticalCenter:parent.verticalCenter
    MouseArea{
    anchors.fill:parent
    //Togglethe'collapsed'property
    onClicked:nestedModel.setProperty(index,"collapsed",!collapsed)
    }
    }
    }
    Loader{
    id:subItemLoader
    //Thisisaworkaroundforabug/featureintheLoaderelement.IfsourceComponentissettonull
    //theLoaderelementretainsthesameheightithadwhensourceComponentwasset.Settingvisible
    //tofalsemakestheparentColumntreatitasifit'sheightwas0.
    visible:!collapsed
    propertyvariantsubItemModel:subItems
    sourceComponent:collapsed?null:subItemColumnDelegate
    onStatusChanged:if(status==Loader.Ready)item.model=subItemModel
    }
    }
    }
    Component{
    id:subItemColumnDelegate
    Column{
    propertyaliasmodel:subItemRepeater.model
    width:200
    Repeater{
    id:subItemRepeater
    delegate:Rectangle{
    color:"#cccccc"
    height:40
    width:200
    border.color:"black"
    border.width:2
    Text{
    anchors.verticalCenter:parent.verticalCenter
    x:30
    font.pixelSize:18
    text:itemName
    }
    }
    }
    }
    }
    }
    
    
  • 相关阅读:
    opencv 图像轮廓特征 图像面积,轮廓周长,外接矩形、最小外接矩形、最小外接圆、拟合椭圆
    opencv cv.findContours 函数详解 图像轮廓层级 图像轮廓检索方式详解
    opencv 绘制图像轮廓
    opencv 实现图像形态学操作 膨胀和腐蚀 开闭运算 形态学梯度 顶帽和黑帽
    opencv 检测图像边缘 Canny算法应用
    opecv 卷积原理、边缘填充方式、卷积操作详解
    opencv 修改图像对比度、图像亮度
    opencv 实现图像融合
    P1396 营救
    P2296 寻找道路
  • 原文地址:https://www.cnblogs.com/fuyanwen/p/3066660.html
Copyright © 2011-2022 走看看