gpt4 book ai didi

qt - 如何更改 Qml 中 ListView 滚动条的位置

转载 作者:行者123 更新时间:2023-12-04 10:21:14 26 4
gpt4 key购买 nike

我创建了一个带有滚动条的 ListView。像这样

enter image description here

这是我的代码,

ListView {
id: listView;
ScrollBar.vertical: ScrollBar {
id: bar
//x :100 doesn't work
active: true

}
}

就我而言,我想重置滚动条的位置。例如,将滚动条向右移动 5 个像素。我试过 设置“x:” ,但没有用。我该如何解决我的问题。

最佳答案

您可以移动 ScrollBarListView并在 ListView 中引用它与其 id :

ListView {
id: listView
ScrollBar.vertical: bar
}

ScrollBar {
id: bar
active: true
anchors {
left: listView.left
top: listView.top
bottom: listView.bottom
leftMargin: 100
}
}

关于qt - 如何更改 Qml 中 ListView 滚动条的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49291944/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com