繁体   English   中英

我如何在QML中设置StyleSheet?(仅QML没有C ++)

[英]How can i setStyleSheet in QML?(only QML no C++)

我想创建一个自定义滚动条。

在此处输入图片说明

这是我的代码,我想在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
  } 
}

就我而言,我想用Scrollbar image创建。

我尝试了“ source:“ ./bar.bng” ”,但是它说ScrollBar没有参数“ source”。 我如何使用自定义图像。

样式表(用于QWidget的格式为.qss文件) 不用于QML

这里是如何实现它们的示例。

对于您的确切用例,请查看Customizing ScrollBar

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM