3

I have used so many combo boxes recently but there is an issue in the popup of a particular ComboBox which I am not able to find the exact problem following is the code:

import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    ComboBox{
        id:comboNum
        width:parent.width * 0.30
        height:parent.height * 0.15
        model: ["12","23","78","23","45","70"]
        currentIndex: 0

        popup: Popup{
            id:popup
            y: comboNum.height - 1
            width: comboNum.width
            height: comboNum.height * 2
            padding: 1

            contentItem: ListView {
                id: listview
                implicitHeight: popup.height
                clip: true
                model:comboNum.delegateModel
                currentIndex: comboNum.highlightedIndex
                interactive: true
                highlightMoveDuration: 0
                boundsBehavior: ListView.StopAtBounds

                ScrollBar.vertical:ScrollBar {}
            }
        }
    }
}

The popup doesn't show up all the elements and i am using QT 5.9.1.

pra7
  • 834
  • 2
  • 21
  • 50

1 Answers1

2

Looking at the customisation docs, I can see that it sets a model conditionally, based on whether or not the popup is visible. Doing the same for your snippet makes it work for me:

model: popup.visible ? comboNum.delegateModel : null

However, the Default style implementation of ComboBox doesn't do that, so I'm not sure why it's necessary in your case.

Mitch
  • 23,716
  • 9
  • 83
  • 122
  • 1
    Oh this is something weird. I never thought that this will be the issue. Will try to figure it out why should we do that !!! based on the visibility – pra7 Jun 02 '18 at 07:51