当我尝试在选项卡中显示对话框或弹出窗口时出现此错误。我不明白为什么。在我制作的其他应用程序中,它有效,但我看不出它们之间的区别。
我做错了什么?
我制作了一个具有完全相同问题的示例代码:
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.")
}
}
}
}
}
}
答案 0 :(得分:0)
我搞定了!问题是我试图通过点击工具栏来显示一个对话框,或者其他什么,这是实际窗口中的其他内容。
所以我只是将工具栏onTriggered中的ID更改为窗口中的项目,在本例中是一个ID为owMap的WebView。旧的id是两行并且注释掉了。
现在有效!
// Change coordinates
Action {
id: coordinateAction
objectName: "action2"
iconSource: Qt.resolvedUrl("toolbarIcon.png")
text: i18n.tr("Coordinates")
onTriggered: {
//PopupUtils.open(dialog, coordinateAction)
PopupUtils.open(cooDialog, owMap)
console.debug('Debug: Change coordinates pressed')
}
}