QML ComboBox 弹出问题

QML ComboBox Popup Issue

我最近使用了很多组合框,但在特定 ComboBox 的弹出窗口中存在问题,我无法找到确切的问题,以下是代码:

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 {}
            }
        }
    }
}

弹出窗口没有显示所有元素,我使用的是 QT 5.9.1。

查看 customisation docs,我可以看到它根据弹出窗口是否可见有条件地设置模型。对您的代码段执行相同的操作使其对我有用:

model: popup.visible ? comboNum.delegateModel : null

但是,Default style implementation of ComboBox 不会这样做,所以我不确定为什么在您的情况下需要这样做。