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. How in ComboBox to make a dropdown list by the width of the text
Forum Update on Monday, May 27th 2025

How in ComboBox to make a dropdown list by the width of the text

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 660 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.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by
    #1

    Hi!
    How in ComboBox to make a dropdown list by the width of the text?

    JonBJ 1 Reply Last reply
    0
    • M Mihaill

      Hi!
      How in ComboBox to make a dropdown list by the width of the text?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Mihaill
      What does this mean? I believe that by default Qt combo boxes automatically size the dropdown to accommodate the widest text in the choices, is that what you mean, is that not the case?

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mihaill
        wrote on last edited by
        #3

        Yeah, that's what I meant.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mihaill
          wrote on last edited by
          #4

          Did so, but now does not change currentindex

                      delegate: ItemDelegate {
                          width: comboBoxProfilOptions.width
                          height: 25
                          highlighted: comboBoxProfilOptions.highlightedIndex === index
                          hoverEnabled: comboBoxProfilOptions.hoverEnabled
                          Rectangle{
                              anchors.fill: parent
                              border.width: 1
                              border.color: "black"
                              color: "#00000000"
                          }
                          
                          Label{
                              x: 3
                              anchors.verticalCenter: parent.verticalCenter
                              width: parent.width
                              text: text1
                              font.pixelSize: comboBoxProfilOptions.font.pixelSize
                              //color: "red"
                          }
                      }
          
          1 Reply Last reply
          0
          • Shrinidhi UpadhyayaS Offline
            Shrinidhi UpadhyayaS Offline
            Shrinidhi Upadhyaya
            wrote on last edited by
            #5

            Hi @Mihaill , can you explain a bit better?Are you telling you are not able to change the currentIndex in the comboBox or are you telling that you are able to customize the current selected item i.e,
            ebfae5c7-75d4-4161-8c64-39920cf518d0-image.png

            Shrinidhi Upadhyaya.
            Upvote the answer(s) that helped you to solve the issue.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mihaill
              wrote on last edited by
              #6

              With this delegate, I can either display delegates without text but select the text I want, or display text in delegates but not select the text I want. You don't know the delegate samples for ComboBox?

              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