首页 > 其他 > 详细

QML实现单选按钮(2)

时间:2018-09-29 19:02:32      阅读:294      评论:0      收藏:0      [点我收藏+]

这里使用了高亮代理


import QtQuick 2.0

Item {
    id: root

    width: 1920
    height: 1080

    Component {
        id: highlightDelegate
        Rectangle {
            width: 100
            height: 50
            color: "transparent"
            border.color: "red"
            z:1
        }
    }

    ListView {
        width: 600
        height: 800
        anchors.centerIn: parent

        model: 5
        delegate: Rectangle {
            id: delegateItem
            width: 100
            height: 50
            color: "lightblue"
            Text {
                anchors.centerIn: parent
                text: index
                font.pixelSize: 30
            }
            border.color: "black"

            MouseArea {
                anchors.fill: parent
                onClicked:  delegateItem.ListView.view.currentIndex = index
            }
        }
        highlight: highlightDelegate
    }


}

QML实现单选按钮(2)

原文:https://www.cnblogs.com/xuexiwrite/p/9722017.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!