Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How-to move vertical scrollbar on left side of ScrollView?
Forum Update on Monday, May 27th 2025

How-to move vertical scrollbar on left side of ScrollView?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KroMignon
    wrote on 23 Mar 2018, 09:06 last edited by
    #1

    Hi all,

    I have create a custom scrollbar for my ScrollView with a ScrollViewStyle sub class, to have something like this:
    0_1521795892460_2ca6fd4c-115c-4a0a-aade-dbc0d7d555f3-image.png

    But this Scrollbar always appears on right side of the ScrollView, is there a way to move it on the left side?

    Seems to be so easy... but I don't find how to do this!

    Regards

    Fabrice

    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

    J 1 Reply Last reply 23 Mar 2018, 09:18
    0
    • K KroMignon
      23 Mar 2018, 09:06

      Hi all,

      I have create a custom scrollbar for my ScrollView with a ScrollViewStyle sub class, to have something like this:
      0_1521795892460_2ca6fd4c-115c-4a0a-aade-dbc0d7d555f3-image.png

      But this Scrollbar always appears on right side of the ScrollView, is there a way to move it on the left side?

      Seems to be so easy... but I don't find how to do this!

      Regards

      Fabrice

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 23 Mar 2018, 09:18 last edited by
      #2

      @KroMignon
      hi,

      looking through the implementation, it says that the vertical scrollbar is anchored to the right:

      ScrollBar {
              id: vscrollbar
              readonly property int scrollAmount: contentHeight - availableHeight
              readonly property bool scrollable: scrollAmount > 0
              isTransient: !!__panel && !!__panel.isTransient
              active: !!__panel && (__panel.sunken || __panel.activeControl !== "none")
              enabled: !isTransient || __panel.visible
              orientation: Qt.Vertical
              visible: verticalScrollBarPolicy === Qt.ScrollBarAsNeeded ? scrollable : verticalScrollBarPolicy === Qt.ScrollBarAlwaysOn
              width: visible ? implicitWidth : 0
              z: 1
              anchors.bottom: cornerFill.top
              maximumValue: scrollable ? scrollAmount + __viewTopMargin : 0
              minimumValue: 0
              anchors.right: parent.right
              anchors.top: parent.top
              anchors.topMargin: __scrollBarTopMargin + topMargin
              anchors.rightMargin: rightMargin
              onScrollAmountChanged: {
                  if (flickableItem && (flickableItem.atYBeginning || flickableItem.atYEnd)) {
                      value = flickableItem.contentY - flickableItem.originY
                  }
              }
              onValueChanged: {
                  if (flickableItem && !blockUpdates && enabled) {
                      flickableItem.contentY = value + flickableItem.originY
                  }
              }
              Binding {
                  target: vscrollbar.__panel
                  property: "raised"
                  value: hscrollbar.active || scrollHelper.active
                  when: vscrollbar.isTransient
              }
              Binding {
                  target: vscrollbar.__panel
                  property: "visible"
                  value: true
                  when: !vscrollbar.isTransient || scrollHelper.active
              }
              function flash() {
                  if (vscrollbar.isTransient) {
                      vscrollbar.__panel.on = true
                      vscrollbar.__panel.visible = true
                      vFlasher.start()
                  }
              }
              Timer {
                  id: vFlasher
                  interval: 10
                  onTriggered: vscrollbar.__panel.on = false
              }
          }
      

      So i don't think you can change it.

      But you should be able can make your own Scrollbar component and place it wherever you like it to be.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      K 1 Reply Last reply 23 Mar 2018, 14:45
      1
      • J J.Hilk
        23 Mar 2018, 09:18

        @KroMignon
        hi,

        looking through the implementation, it says that the vertical scrollbar is anchored to the right:

        ScrollBar {
                id: vscrollbar
                readonly property int scrollAmount: contentHeight - availableHeight
                readonly property bool scrollable: scrollAmount > 0
                isTransient: !!__panel && !!__panel.isTransient
                active: !!__panel && (__panel.sunken || __panel.activeControl !== "none")
                enabled: !isTransient || __panel.visible
                orientation: Qt.Vertical
                visible: verticalScrollBarPolicy === Qt.ScrollBarAsNeeded ? scrollable : verticalScrollBarPolicy === Qt.ScrollBarAlwaysOn
                width: visible ? implicitWidth : 0
                z: 1
                anchors.bottom: cornerFill.top
                maximumValue: scrollable ? scrollAmount + __viewTopMargin : 0
                minimumValue: 0
                anchors.right: parent.right
                anchors.top: parent.top
                anchors.topMargin: __scrollBarTopMargin + topMargin
                anchors.rightMargin: rightMargin
                onScrollAmountChanged: {
                    if (flickableItem && (flickableItem.atYBeginning || flickableItem.atYEnd)) {
                        value = flickableItem.contentY - flickableItem.originY
                    }
                }
                onValueChanged: {
                    if (flickableItem && !blockUpdates && enabled) {
                        flickableItem.contentY = value + flickableItem.originY
                    }
                }
                Binding {
                    target: vscrollbar.__panel
                    property: "raised"
                    value: hscrollbar.active || scrollHelper.active
                    when: vscrollbar.isTransient
                }
                Binding {
                    target: vscrollbar.__panel
                    property: "visible"
                    value: true
                    when: !vscrollbar.isTransient || scrollHelper.active
                }
                function flash() {
                    if (vscrollbar.isTransient) {
                        vscrollbar.__panel.on = true
                        vscrollbar.__panel.visible = true
                        vFlasher.start()
                    }
                }
                Timer {
                    id: vFlasher
                    interval: 10
                    onTriggered: vscrollbar.__panel.on = false
                }
            }
        

        So i don't think you can change it.

        But you should be able can make your own Scrollbar component and place it wherever you like it to be.

        K Offline
        K Offline
        KroMignon
        wrote on 23 Mar 2018, 14:45 last edited by
        #3

        @J.Hilk thanks for your help. In fact, it seems not to be supported :(

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        1 Reply Last reply
        0

        1/3

        23 Mar 2018, 09:06

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved