0

I'd like to make a ScrollView's scroll bar wider than the default value, but I don't see any width properties, even as part of the ScrollViewStyle element's frame component.

Kyle Strand
  • 15,941
  • 8
  • 72
  • 167

1 Answers1

7

To make the scroll bar wider, you can change the following four properties in ScrollViewStyle with your custom components: handle, scrollBarBackground, decrementControl, and incrementControl (it may look weird if you do not change all of them). For example,

ScrollView {
    style: ScrollViewStyle {
        handle: Rectangle {
            implicitWidth: 50
            implicitHeight: 30
            color: "red"
        }
        scrollBarBackground: Rectangle {
            implicitWidth: 50
            implicitHeight: 30
            color: "black"
        }
        decrementControl: Rectangle {
            implicitWidth: 50
            implicitHeight: 30
            color: "green"
        }
        incrementControl: Rectangle {
            implicitWidth: 50
            implicitHeight: 30
            color: "blue"
        }
    }
    //...
}

and it looks like this:

custom scroll bar

mcchu
  • 3,309
  • 1
  • 20
  • 19
  • ...Meaning that I need to re-implement the entire appearance of the scroll-bars? Is there some way to just use the default grey-on-grey-with-arrows scheme, or an easy way to re-implement that? – Kyle Strand Apr 11 '16 at 16:43
  • In addition, as-is, this appears to cause several "`TextArea.qml:: Unable to assigne [undefined] to `" errors, and my screen flashes in a weird way. How can I figure out what a minimal complete working `ScrollViewStyle` would actually consist of? – Kyle Strand Apr 11 '16 at 17:12
  • .....actually, the reason this isn't working might be because I'm not using a `ScrollView` directly, I'm using a `TextArea`, which *inherits from* `ScrollView`. The only `style` member in `TextArea` [appears to be the one it inherits from `ScrollView`](http://doc.qt.io/qt-5/qml-qtquick-controls-textarea-members.html), though, so I'm still not sure why I can't just assign a `ScrollViewStyle` to `TextView`'s `style` property. – Kyle Strand Apr 11 '16 at 19:01
  • Unfortunately, you have to re-implement the entire appearance since QtQuick control style does not provide any method for you to override some of the properties (ex. width) in the default component. For `TextArea` style, try [TextAreaStyle](http://doc.qt.io/qt-5/qml-qtquick-controls-styles-textareastyle.html), which inherits from `ScrollViewStyle`. – mcchu Apr 12 '16 at 01:39
  • 1
    Thank you very much! Changing `ScrollViewStyle` to `TextAreaStyle` works perfectly, without even defining any extra properties. – Kyle Strand Apr 12 '16 at 02:24