簡體   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