我有一个qml文件

Flickable{
    id: view
    anchors.fill: parent
    contentHeight:300
    contentWidth:parent.width
    Grid {            
        id: grid
        //items
    }
}

我已经添加了一些项目到网格 . 现在它可以工作但是当我移动flickable看到其他项目时,它将返回旧位置我想在滚动时显示滚动条我想要停止在移动它的位置我想要能够用鼠标滚动它因为我想要发布我的桌面和移动应用程序 .

Edit 我改变了下面的代码并添加了滚动条 . 但它不起作用

Rectangle{
    id:root
    color: "#90dfaa"
    Flickable{
        id: view
        anchors.fill: parent
        contentHeight:300
        contentWidth:parent.width
        y: -sb.position * grid.height
        Grid {
            id:grid
        }
    }
ScrollBar {
    id: sb
     hoverEnabled: true
    active: hovered || pressed
    orientation: Qt.Vertical
    size:100// grid.height/root  .height // the probelm is here
    anchors.top: grid.top
    anchors.right: grid.right
    anchors.bottom: grid.bottom
        }
}