1

有 QML 控件 ScrollBar ,鼠标滚轮快速滚动列表,我需要慢一点执行。可以使用哪些属性?

Qt 5.9

这是来自一个示例(来自 Qt 工具包的 rssnews 示例项目):

...
ListView {
    id: categories
    property int itemWidth: 190


    width: isPortrait ? parent.width : itemWidth
    height: isPortrait ? itemWidth : parent.height
    orientation: isPortrait ? ListView.Horizontal : ListView.Vertical
    anchors.top: parent.top
    model: rssFeeds
    delegate: CategoryDelegate { itemSize: categories.itemWidth }
    spacing: 3
}

ScrollBar {
    id: listScrollBar

    orientation: isPortrait ? Qt.Horizontal : Qt.Vertical
    height: isPortrait ? 8 : categories.height;
    width: isPortrait ? categories.width : 8
    scrollArea: categories;

    anchors.right: categories.right
}
...

我在ScrollView看到了这个:

/*! \internal */
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed

但是找不到适合我的情况的 scrollSpeed 属性...

4

2 回答 2

2

我不认为ScrollBar是什么让事情变得疯狂。它是Flickable的基类ListView

那里有属性:maximumFlickVelocity它以像素/秒为单位。

尝试将其设置为适当的值。

这也会影响轻弹行为!

如果是,ScrollBar您可以尝试该属性:stepSize- 将其设置为小于0.1. 我没有Qt5.9,所以无法尝试。我不相信这是原因。

在最坏的情况下,MouseArea在整个事物的顶部分层,不接受任何按钮,但处理onWheel

MouseArea {
    anchors.fill: parent
    acceptedButtons: Qt.NoButton
    //onWheel: manage the scrolling yourself, here.
}
于 2017-12-06T23:01:33.537 回答
0

在 ListView 顶部包装一个 MouseArea(如提到的 derM)是我的解决方案。现在 ListView 对鼠标滚轮做出反应。

MouseArea {
    anchors.fill: parent
    ListView {
        id: lv
        anchors.fill: parent
        delegate: ...
        ScrollBar.vertical: ScrollBar {
            parent: lv.parent
            anchors.top: lv.top
            anchors.left: lv.right
            anchors.bottom: lv.bottom
        }
    }
}
于 2018-04-26T12:32:39.777 回答