QML滚动栏/listView鼠标滚轮灵敏度.如何调整



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

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

,但找不到我的案件的卷轴属性...

我不认为ScrollBar是使事情变得疯狂的原因。是FlickableListView的基类。

您有属性: pixel/second

中的 maximumFlickVelocity

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

这也会影响闪烁的行为!

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

在最坏的情况下,将整个 MouseArea ontop the Aly A The The Thing,不接受任何按钮,而是处理onWheel

MouseArea {
    anchors.fill: parent
    acceptedButtons: Qt.NoButton
    //onWheel: manage the scrolling yourself, here.
}

在listView的顶部包裹鼠标(如Derm所述)是我的解决方案。现在列表视图在鼠标轮上反应。

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
        }
    }
}

最新更新