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. Slider support for tickmarks?
Forum Updated to NodeBB v4.3 + New Features

Slider support for tickmarks?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 4 Posters 877 Views 1 Watching
  • 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    Re: How to add tick marks in QML Slider: QtQuick.Controls 1.x provided a tickmarksEnabled property, but QtQuick.Controls 2 removed that property for some reason - why? Is there a straightforward way to support this extremely common use case?
    Thanks!

    Pl45m4P GrecKoG 2 Replies Last reply
    0
    • Tom assoT Tom asso

      Re: How to add tick marks in QML Slider: QtQuick.Controls 1.x provided a tickmarksEnabled property, but QtQuick.Controls 2 removed that property for some reason - why? Is there a straightforward way to support this extremely common use case?
      Thanks!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Tom-asso

      If you look at the example animation from the latest version of documentation (Qt 6.7), you can see a slider having tick marks...

      • https://doc.qt.io/qt-6/qml-qtquick-controls-slider.html#snapMode-prop

      But dont ask me how it's done ;-)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      MarkkyboyM 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @Tom-asso

        If you look at the example animation from the latest version of documentation (Qt 6.7), you can see a slider having tick marks...

        • https://doc.qt.io/qt-6/qml-qtquick-controls-slider.html#snapMode-prop

        But dont ask me how it's done ;-)

        MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #3

        @Pl45m4 - That has nothing to do with visible tickmarks, those are just methods to control slider with stepping size. There does not seem to be any provision with later/current versions of Qt. If stepSize it set, the slider will pause at intervals as if it were inline with a corresponding tickmark, instead, we use 'label'.

        Don't just sit there standing around, pick up a shovel and sweep up!

        I live by the sea, not in it.

        Pl45m4P 1 Reply Last reply
        0
        • MarkkyboyM Markkyboy

          @Pl45m4 - That has nothing to do with visible tickmarks, those are just methods to control slider with stepping size. There does not seem to be any provision with later/current versions of Qt. If stepSize it set, the slider will pause at intervals as if it were inline with a corresponding tickmark, instead, we use 'label'.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          @Markkyboy

          I'm not talking about the slide bahaviour... just look at the slider there. There are ticks beneath the slider


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          MarkkyboyM 1 Reply Last reply
          0
          • Pl45m4P Pl45m4

            @Markkyboy

            I'm not talking about the slide bahaviour... just look at the slider there. There are ticks beneath the slider

            MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by
            #5

            @Pl45m4 - they are example/legacy images, probably from previous releases of Slider, it looks to me like 'tickmarks' were dropped in releases beyond 5.15 https://doc.qt.io/qt-5/qml-qtquick-controls-slider.html seeing as QtQuick.Controls 1.4 is also obsolete.

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            Tom assoT 1 Reply Last reply
            0
            • MarkkyboyM Markkyboy

              @Pl45m4 - they are example/legacy images, probably from previous releases of Slider, it looks to me like 'tickmarks' were dropped in releases beyond 5.15 https://doc.qt.io/qt-5/qml-qtquick-controls-slider.html seeing as QtQuick.Controls 1.4 is also obsolete.

              Tom assoT Offline
              Tom assoT Offline
              Tom asso
              wrote on last edited by
              #6

              @Markkyboy - thanks for the feedback guys. So there is apparently no "easy" way to add tickmarks then? That is really too bad - tickmarks are such a very very common use case for sliders!

              1 Reply Last reply
              0
              • MarkkyboyM Offline
                MarkkyboyM Offline
                Markkyboy
                wrote on last edited by Markkyboy
                #7

                @Tom-asso - it does seem that way. I've been making speedometers using a CircularSlider, which did not have tickmarks, so i had to find a way to add tickmarks. I did this using Repeater with Rectangle for ticks and Label for digits.

                This works; kinda, it's crude somewhat and not entirely accurate to the eye;

                ```
                Column {
                     id: column
                    width: parent.width
                    anchors.centerIn: parent
                
                    Slider {
                        value: 0.5
                        width: 1000
                        stepSize: 0.1
                        minimumValue: 0.0
                        maximumValue: 1.0
                        anchors.horizontalCenter: parent.horizontalCenter
                
                        Row {
                            spacing: 68
                            anchors {
                                verticalCenterOffset: 40
                                verticalCenter: parent.verticalCenter
                                horizontalCenter: parent.horizontalCenter
                            }
                            Repeater {
                                model: 11
                                Rectangle {
                                    width: 2
                                    height: 25
                                    Label {
                                        text: index
                                        font.pixelSize: 48
                                        x: -12.5; y: 30
                                    }
                                }
                            }
                        }
                    }
                }
                

                Don't just sit there standing around, pick up a shovel and sweep up!

                I live by the sea, not in it.

                1 Reply Last reply
                1
                • Tom assoT Tom asso

                  Re: How to add tick marks in QML Slider: QtQuick.Controls 1.x provided a tickmarksEnabled property, but QtQuick.Controls 2 removed that property for some reason - why? Is there a straightforward way to support this extremely common use case?
                  Thanks!

                  GrecKoG Online
                  GrecKoG Online
                  GrecKo
                  Qt Champions 2018
                  wrote on last edited by
                  #8

                  @Tom-asso For some reason the Material style Slider has tickmarks when snapMode is SnapAlways and it has a suited stepSize. It doesn't seem other modes have tickmarks.

                  You could add it to the background with a Repeater of Rectangle.

                  Pl45m4P 1 Reply Last reply
                  3
                  • GrecKoG GrecKo

                    @Tom-asso For some reason the Material style Slider has tickmarks when snapMode is SnapAlways and it has a suited stepSize. It doesn't seem other modes have tickmarks.

                    You could add it to the background with a Repeater of Rectangle.

                    Pl45m4P Offline
                    Pl45m4P Offline
                    Pl45m4
                    wrote on last edited by
                    #9

                    @GrecKo

                    That's what I meant... the documentation shows the tick marks in some subsection


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    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