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. qt.labs.controls - customizing Tumbler - Material
QtWS25 Last Chance

qt.labs.controls - customizing Tumbler - Material

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt.labs.controlmaterial designandroid
5 Posts 2 Posters 2.6k 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.
  • ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #1

    I tried to customize the Tumbler.
    a) selected number with accent color and slightly larger font and something less spacing between values
    b) slightly larger font and at top and bottom of selected number a small line in accent color saimilar to TabButton

    a) got it working for color and font size, but didn't found out HowTo change the spacing

    Tumbler {
    	id: tumbler
    	model: 10
    	visibleItemCount: 5
    	delegate: Text {
    		property int displacement: Math.abs(Tumbler.displacement)
    			id: label
    			text: modelData
    			color: displacement == 1 ? Material.accentColor : "darkGray"
    			font: tumbler.font
    			scale: displacement == 1 ? 1.25 : 1.0
    			horizontalAlignment: Text.AlignHCenter
    			verticalAlignment: Text.AlignVCenter
    	}
    }
    

    any ideas HowTo change the space between the values ?

    b) have no idea HowTo draw the accent colored lines

    thx helping

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    ekkescornerE 1 Reply Last reply
    0
    • ekkescornerE ekkescorner

      I tried to customize the Tumbler.
      a) selected number with accent color and slightly larger font and something less spacing between values
      b) slightly larger font and at top and bottom of selected number a small line in accent color saimilar to TabButton

      a) got it working for color and font size, but didn't found out HowTo change the spacing

      Tumbler {
      	id: tumbler
      	model: 10
      	visibleItemCount: 5
      	delegate: Text {
      		property int displacement: Math.abs(Tumbler.displacement)
      			id: label
      			text: modelData
      			color: displacement == 1 ? Material.accentColor : "darkGray"
      			font: tumbler.font
      			scale: displacement == 1 ? 1.25 : 1.0
      			horizontalAlignment: Text.AlignHCenter
      			verticalAlignment: Text.AlignVCenter
      	}
      }
      

      any ideas HowTo change the space between the values ?

      b) have no idea HowTo draw the accent colored lines

      thx helping

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @ekkescorner any ideas or hints ? - thx

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

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

        It sounds like you would have to replace the builtin contentItem, which is a PathView. You could copy the one from http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/material/Tumbler.qml and use it as a starting point and tweak the path to your needs.

        ekkescornerE 2 Replies Last reply
        0
        • jpnurmiJ jpnurmi

          It sounds like you would have to replace the builtin contentItem, which is a PathView. You could copy the one from http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/material/Tumbler.qml and use it as a starting point and tweak the path to your needs.

          ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #4

          @jpnurmi thx for the hint.
          then at first I have to learn what a PathView is ;-)

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
          5.15 --> 6.8 https://t1p.de/ekkeChecklist
          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

          1 Reply Last reply
          0
          • jpnurmiJ jpnurmi

            It sounds like you would have to replace the builtin contentItem, which is a PathView. You could copy the one from http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/material/Tumbler.qml and use it as a starting point and tweak the path to your needs.

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #5

            @jpnurmi thx again
            only had to change the implicitHeight:

            Tumbler {
                id: tumbler
                model: 10
                visibleItemCount: 5
                implicitHeight: visibleItemCount * 24
                delegate: Text {
                    property int displacement: Math.abs(Tumbler.displacement)
                    id: label
                    text: modelData
                    color: displacement == 0 ? Material.primaryTextColor : Material.secondaryTextColor
                    font: tumbler.font
                    scale: displacement == 0 ? 1.20 : 1.0
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter
                }
            }
            

            while flicking the tumbler there's a noticable delay before only the selected number will be scaled,
            but I can live with this.

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.8 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            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