QML ListView 實現 滾動條方式

import QtQuick 2.0
import QtQuick.Controls 2.1
Rectangle {
    id: rect
    width: 1920
    height:1180

    color:"black"
    ListView {
        id: list_view
        anchors.fill:parent
        model: 16        //16個model
        delegate: Rectangle { x:0; y:0;width: 300; height: 50;        //代理
        border.color: 'grey' }
        spacing: 6

        ScrollBar.vertical: ScrollBar {       //滾動條
            anchors.right: lview.left
            width: 50
            active: true
            background: Item {            //滾動條的背景樣式
                Rectangle {
                    anchors.centerIn: parent
                    height: parent.height
                    width: parent.width * 0.2
                    color: 'grey'
                    radius: width/2
                }
            }

            contentItem: Rectangle {
                radius: width/3        //bar的圓角
                color: 'yellow'
            }
        }
    }

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章