当前位置 : 首页 > 文章 > 关于Qt中的ComboBox嵌套Bug及修复方法

关于Qt中的ComboBox嵌套Bug及修复方法

来源:推好下载站Gamer发布时间: 2024-11-12 10:13:56

最近发现在编写信息提交表单的窗口时,遇到了一个奇怪的BUG:

其代码如下:

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
    Button{ text: "open" onClicked: popup.open();}
    Popup {
        id: popup
        width: 400
        height: 200
        anchors.centerIn: parent
        clip: true
        closePolicy: Popup.CloseOnPressOutside
        background: Rectangle { color: "#80800000"}
        contentItem: Flickable {
            id: flickable
            clip: true
            topMargin: 10
            contentWidth: implicitWidth
            contentHeight: 500
            ScrollBar.vertical: ScrollBar { width: 14 }
            ComboBox {
                width: 160
                height: 40
                objectName: "__ComboBox__"
                model: ["aaaaaa", "bbbbbb", "cccccc", "dddddd"]
            }
        }
    }
}