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. Any way to customize the appearance of TextArea/ScrollView scrollbars?
QtWS25 Last Chance

Any way to customize the appearance of TextArea/ScrollView scrollbars?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 2 Posters 3.1k 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.
  • V Offline
    V Offline
    VRHans
    wrote on last edited by
    #1

    The defaults are system scrollbars which look horrible in my quite pretty QML user interface.

    Do I have to roll my own? I didn't see any scroll view style options for changing the color or the shape.

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by
      #2

      Notice that TextAreaStyle inherits ScrollViewStyle.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VRHans
        wrote on last edited by
        #3

        I found that earlier and used it to modify some aspects, but I need to affect the scroll bars and there are virtually no settings for those.

        1 Reply Last reply
        0
        • jpnurmiJ Offline
          jpnurmiJ Offline
          jpnurmi
          wrote on last edited by
          #4

          Try these:

          • handle: http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#handle-prop
          • scrollBarBackground: http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#scrollBarBackground-prop
          • transientScrollBars: http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#transientScrollBars-prop
          1 Reply Last reply
          0
          • V Offline
            V Offline
            VRHans
            wrote on last edited by
            #5

            @jpnurmi said:

            http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#handle-prop

            Are you just guessing or have you actually changed the appearance of the scrollbars to something custom?

            I've seen all of the properties you've liniked to and they (according to the documentation) only expose boolean properties relating to behavior.

            jpnurmiJ 1 Reply Last reply
            0
            • V VRHans

              @jpnurmi said:

              http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#handle-prop

              Are you just guessing or have you actually changed the appearance of the scrollbars to something custom?

              I've seen all of the properties you've liniked to and they (according to the documentation) only expose boolean properties relating to behavior.

              jpnurmiJ Offline
              jpnurmiJ Offline
              jpnurmi
              wrote on last edited by
              #6

              @VRHans said:

              Are you just guessing or have you actually changed the appearance of the scrollbars to something custom?

              No, I'm not guessing. I have been involved in implementing that stuff a couple of years ago.

              I've seen all of the properties you've liniked to and they (according to the documentation) only expose boolean properties relating to behavior.

              The handle property is a Component that defines the Item that represents a handle. The styleData boolean properties are defined in the context of that item.

              import QtQuick 2.5
              import QtQuick.Controls 1.3
              import QtQuick.Controls.Styles 1.3
              
              ApplicationWindow {
                  id: window
                  width: 640
                  height: 480
                  visible: true
              
                  TextArea {
                      anchors.fill: parent
                      Component.onCompleted: {
                          for (var i = 0; i < 100; ++i)
                              append("foo bar " + i)
                      }
              
                      style: TextAreaStyle {
                          incrementControl: null
                          decrementControl: null
                          transientScrollBars: true
                          handle: Rectangle {
                              implicitWidth: 20
                              implicitHeight: 20
                              color: styleData.pressed ? "dimgray" : "gray"
                          }
                          scrollBarBackground: Rectangle {
                              implicitWidth: 20
                              implicitHeight: 20
                              color: "#33000000"
                          }
                      }
                  }
              }
              
              V 1 Reply Last reply
              1
              • V Offline
                V Offline
                VRHans
                wrote on last edited by
                #7

                @jpnurmi said:

                http://doc.qt.io/qt-5/qml-qtquick-controls-styles-scrollviewstyle.html#scrollBarBackground-prop

                Ahhh... That makes sense, apologies. The documentation is very confusing because it very much makes it sound like only the two state properties can be affected: "You can access the following state properties"

                What it means to say is something like "You can define the component, and that component will have the following state properties added to it that don't usually sit on a component."

                I'll give that a try, thanks.

                1 Reply Last reply
                0
                • jpnurmiJ jpnurmi

                  @VRHans said:

                  Are you just guessing or have you actually changed the appearance of the scrollbars to something custom?

                  No, I'm not guessing. I have been involved in implementing that stuff a couple of years ago.

                  I've seen all of the properties you've liniked to and they (according to the documentation) only expose boolean properties relating to behavior.

                  The handle property is a Component that defines the Item that represents a handle. The styleData boolean properties are defined in the context of that item.

                  import QtQuick 2.5
                  import QtQuick.Controls 1.3
                  import QtQuick.Controls.Styles 1.3
                  
                  ApplicationWindow {
                      id: window
                      width: 640
                      height: 480
                      visible: true
                  
                      TextArea {
                          anchors.fill: parent
                          Component.onCompleted: {
                              for (var i = 0; i < 100; ++i)
                                  append("foo bar " + i)
                          }
                  
                          style: TextAreaStyle {
                              incrementControl: null
                              decrementControl: null
                              transientScrollBars: true
                              handle: Rectangle {
                                  implicitWidth: 20
                                  implicitHeight: 20
                                  color: styleData.pressed ? "dimgray" : "gray"
                              }
                              scrollBarBackground: Rectangle {
                                  implicitWidth: 20
                                  implicitHeight: 20
                                  color: "#33000000"
                              }
                          }
                      }
                  }
                  
                  V Offline
                  V Offline
                  VRHans
                  wrote on last edited by
                  #8

                  @jpnurmi - That worked great, thanks. Just enough control to make it fit in visually.

                  1 Reply Last reply
                  0

                  • Login

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