当前位置:   article > 正文

Qt_Note14_QML_Repeater

Qt_Note14_QML_Repeater
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("My QML")
    color: "white"

    Repeater {
//          model: 3  //模型 可以是很多类型 数字的话 表示有几个模型/控件
        model: ["Button", "Rectangle", "MouseArea"] //数量还是3 读取list大小
          Button {
              y: index * 50 //index表示第几个
              width: 100; height: 40
//              border.width: 1
//              color: "yellow"
              text: modelData + index  //获取List里的数据
          }
          Component.onCompleted: {
              console.log(count)
          }
      }
 }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/418274
推荐阅读
相关标签
  

闽ICP备14008679号