我正在使用 Qt 5.7 和 QtQuick.Controls 2.0。我想让我ComboBox
的默认打开。为了做到这一点,我只是简单地设置popup.visible
为 true,但不幸的是,我在控制台中收到以下错误:QML Popup: cannot find any window to open popup in.
. 单击我的 ComboBox 打开和关闭它就好了,没有任何错误消息。我什至尝试过Component.onCompleted: _popup.open()
,我的 ComboBox 中的 Popup 组件在哪里,但出现了相同的错误消息_popup
。id
编辑1(添加一个简单的例子):
ApplicationWindow {
width: 200
height: 200
Item {
anchor.fill: parent
ComboBox {
popup.visible: true
model: ["First", "Second", "Third"]
}
}