Q:

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

I want to create a custom Scrollbar.Like this.

This is my code, i want to use ScrollBar component in Qml.
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
  } 
}

In my case, i want to create with my Scrollbar image.
I tried「source: "./bar.bng" 」,but it said ScrollBar haven't have the parameter "source". How can i use custom image.

A:

Stylesheets (in a form of .qss files, as used for QWidget's) are not used for QML.
Here are examples of how you can implement them though.
For your exact use-case, check out Customizing ScrollBar

