Important: Please read the Qt Code of Conduct -

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

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

  • @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?

  • Yeah, that's what I meant.

  • Did so, but now does not change currentindex

                delegate: ItemDelegate {
                    width: comboBoxProfilOptions.width
                    height: 25
                    highlighted: comboBoxProfilOptions.highlightedIndex === index
                    hoverEnabled: comboBoxProfilOptions.hoverEnabled
                        anchors.fill: parent
                        border.width: 1
                        border.color: "black"
                        color: "#00000000"
                        x: 3
                        anchors.verticalCenter: parent.verticalCenter
                        width: parent.width
                        text: text1
                        font.pixelSize: comboBoxProfilOptions.font.pixelSize
                        //color: "red"

  • 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,

  • 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?

Log in to reply