我想创建一个自定义滚动条。像这样。
这是我的代码,我想在 Qml 中使用 ScrollBar 组件。
Rectangle {
id: frame
clip: true
width: 160
height: 160
border.color: "black"
anchors.centerIn: parent
Text {
id: content
text: "ABC"
font.pixelSize: 160
x: -hbar.position * width
y: -vbar.position * height
}
ScrollBar {
id: vbar
hoverEnabled: true
active: hovered || pressed
orientation: Qt.Vertical
size: frame.height / content.height
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
}
}
在我的例子中,我想用我的滚动条图像来创建。
我试了「source: "./bar.bng" 」,但是说ScrollBar没有参数"source"。我如何使用自定义图像。
最佳答案
关于c++ - 我如何在 QML 中设置样式表?(只有 QML 没有 C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49273738/