QML可滑动不起作用

Axe*_*dal 4 user-interface qt qml qt-quick

我正在尝试学习QML,以便能够创建智能手机应用程序。现在,我正在尝试创建一个列表,其中每个项目都应该是“可滑动的”,这就是我想要的:当您抓取一个列表项目时,应该可以将其向左拖动(以显示下面的菜单),然后实际列表项应该不会完全消失的左侧边缘,但还是有点可见这样你就可以将其拖回。尽可能简单的解决方案将不胜感激:)!

这是我的开始(仅使最后一个矩形可滑动):

import QtQuick 2.0

Rectangle {
    width: 360
    height: 360

    Column {
        spacing: 5
        Rectangle {
            color: "green"
            width: 360
            height: 360/3
        }

        Rectangle {
            color: "red"
            width: 360
            height: 360/3
        }

        Flickable{
            interactive: true
            boundsBehavior: Flickable.StopAtBounds
            contentHeight: flickme.height
            contentWidth: flickme.width
            width: 360
            height: 360/3
            Rectangle {
                id:flickme
                color: "yellow"
                width: 360
                height: 360/3
            }
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

Axe*_*dal 5

我想到了!您只需将设置contentWidth为大于的宽度Flickable

Flickable{
            interactive: true
            boundsBehavior: Flickable.StopAtBounds
            contentHeight: flickme.height
            contentWidth: flickme.width*1.8
            width: 360
            height: 360/3
            Rectangle {
                id:flickme
                color: "yellow"
                width: 360
                height: 360/3
            }
        }
Run Code Online (Sandbox Code Playgroud)