当我尝试在选项卡中显示对话框或弹出窗口时出现此错误。我不明白为什么。在我制作的其他应用程序中,它可以工作,但我看不出它们之间的区别。
我究竟做错了什么?
我制作了一个具有完全相同问题的示例代码:
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import Ubuntu.Components.Popups 0.1
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the .desktop filename
applicationName: "testar"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
automaticOrientation: true
width: units.gu(50)
height: units.gu(75)
Tabs {
id: tabs
// First tab begins here
Tab {
objectName: "Tab1"
title: i18n.tr("Hello..")
// Tab content begins here
page: Page {
Column {
width: parent.width
ListItem.Standard {
text: i18n.tr("Swipe from right to left to change tab.")
}
}
// coordinates popover
Component {
id: popoverComponent
Popover {
id: popover
Column {
id: containerLayout
anchors {
left: parent.left
top: parent.top
right: parent.right
}
ListItem.Header { text: "Standard list items" }
ListItem.Standard { text: "Do something" }
ListItem.Standard { text: "Do something else" }
ListItem.Header { text: "Buttons" }
ListItem.SingleControl {
highlightWhenPressed: false
control: Button {
text: "Do nothing"
anchors {
fill: parent
margins: units.gu(1)
}
}
}
ListItem.SingleControl {
highlightWhenPressed: false
control: Button {
text: "Close"
anchors {
fill: parent
margins: units.gu(1)
}
onClicked: PopupUtils.close(popover)
}
}
}
}
}
tools: ToolbarActions {
// Show spawn again
Action {
objectName: "action1"
id: action1
iconSource: Qt.resolvedUrl("toolbarIcon.png")
text: i18n.tr("Reload")
onTriggered: {
console.debug('Debug: Reload data')
PopupUtils.open(popoverComponent, action1)
}
}
}
}
}
// Second tab begins here
Tab {
objectName: "Tab2"
title: i18n.tr("..Toolbar!")
page: Page {
tools: ToolbarActions {
Action {
objectName: "action"
iconSource: Qt.resolvedUrl("toolbarIcon.png")
text: i18n.tr("Tap me!")
onTriggered: {
label.text = i18n.tr("Toolbar tapped")
}
}
}
Column {
anchors.centerIn: parent
Label {
id: label
objectName: "label"
text: i18n.tr("Swipe from bottom to up to reveal the toolbar.")
}
}
}
}
}
}