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. showing slider in ComboBox using QML
Forum Updated to NodeBB v4.3 + New Features

showing slider in ComboBox using QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.0k 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.
  • S Offline
    S Offline
    Shreyansh K.
    wrote on last edited by
    #1

    So I have this combo box
    old_combobox.jpg

    but requirement is thisneeded_combobox.jpg

    I need slider inside ComboBox since many entries..

    any help/advise would be helpful..

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

      Trying not to be pedantic, but slider is not correct, you are looking for 'scrollview'.

      Similar to what you're asking, try this;

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 50
          height: 200
          visible: true
          title: qsTr("Hello World")
      
          ScrollView {
              id: scrollview
              width: 100
              height: 200
      
              ListView {
                  model: 2000
                  delegate: ItemDelegate {
                      text: "Item " + index
                  }
                  header: headerComponent
              }
              Component {
                  id: headerComponent
                  Text {
                      width: ListView.view.width
                      height: 20
                      text: 'ALL'
                      x: width/2
                  }
              }
          }
      }
      

      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
      0
      • S Offline
        S Offline
        Shreyansh K.
        wrote on last edited by
        #3

        @Markkyboy Thanks for correcting, I tried running above code but it is no different than what mine is, i.e. scrollview functionality is there by default in comboBox, what i am looking for is some indicator to show total items inside scrollview/combobox..

        1 Reply Last reply
        0
        • GrecKoG Offline
          GrecKoG Offline
          GrecKo
          Qt Champions 2018
          wrote on last edited by
          #4

          You can use the fact that the popup's contentItem of the ComboBox is a ListView and use ScrollBar vertical attached property:

          Binding {
              target: comboBox.popup.contentItem.ScrollBar
              property: "vertical"
              value: ScrollBar {
                  policy: ScrollBar.AlwaysOn
              }
          }
          
          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