有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的财产.
发布于 2017-12-06 23:01:33
我不认为是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.
}
发布于 2018-04-26 12:32:39
将一个MouseArea (就像derM提到的那样)包装在ListView上是我的解决方案。现在,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
}
}
}
https://stackoverflow.com/questions/47678380
复制相似问题