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. Tumbler - how to restrict movement?
Qt 6.11 is out! See what's new in the release blog

Tumbler - how to restrict movement?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 2.1k Views 2 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.
  • M Offline
    M Offline
    Marek
    wrote on last edited by
    #1

    Hi all,

    I have Tumbler with one column and a model of minutes 0-100
    I would like to add restriction so the wheel could change values sort of like SpinBox from 0 to 100 but not flip around.
    In other words when Tumbler displays 0 - disable "down" wheel movement, so user cannot select 100
    when Tumbler displays 100 - disable "up" wheel movement so user cannot select 0
    Don't know how to do it. Possible?

    Best Regards
    Marek

    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi @Marek

      This is how you can detect that you have to block mouvement :

                   property int lastIndex
      
                  onCurrentIndexChanged: {
                        lastIndex = currentIndex-1
                       
                         if(lastIndex<0||lastIndex>=(model-2)){
                                  console.log("need lock")
                                 }
                      }
      

      But i don't know how to dynamicaly lock mouvement when user slides and reachs extrem values.

      One solution could be to block mouse interaction (set 'enabled' property to false on the tumbler) and add 2 buttons to select values (+1 / -1), then you can hide button when needed... but this is not exactly what you want i imagine.
      BR
      LA

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

        See Tumbler::wrap

        1 Reply Last reply
        1
        • 6thC6 Offline
          6thC6 Offline
          6thC
          wrote on last edited by 6thC
          #4

          I fixated on Tumbler when I was picking up Qt && QML. If you want just the look and feel of default Tumbler (but not the operation) - you could just style a ListView with the same default gradient Tumbler uses.

          Does nearly the same (except Tumbler always has a currentIndex) with much less.
          https://doc.qt.io/qt-5/qml-qtquick-controls2-tumbler.html

          The (tumbler) API is similar to that of views like ListView and PathView; 
          a model and delegate can be set, and the count and currentItem properties provide read-only access to information about the view.
          
          Unlike views like PathView and ListView, however, there is always a current item
           (when the model is not empty). This means that when count is equal to 0, currentIndex will be -1.
          In all other cases, it will be greater than or equal to 0.
          
          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marek
            wrote on last edited by
            #5

            Hi

            Thanks all for hints.
            I know ListView could do the same as Tumbler but I thought Tumbler will require less code to work ;)
            I went for a Tumbler with "wrap" property and customized it to my needs.

            Don't get me wrong, I like Qt, I do it for a living, but current state of QML objects is a mess.
            There are 2 or 3 types of Tumbler one of them has "wrap" property another has not, they have different look, different property names (currentIndex, setCurrentIndexAt).
            Will this ever be unified like with Qt Widgets?

            Best Regards
            Marek

            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