我很难让包含 PageStack 的 BottomEdge 工作。主要问题是我在 PageStack 上推送的页面在页面的 Component.onCompleted 方法执行后以某种方式调整了大小,我无法弄清楚是什么触发了所说的调整大小。
所有使用的组件都是可点击框架提供的 Ubuntu.Components 库的一部分。 https://api-docs.ubports.com/sdk/apps/qml/Ubuntu.Components/index.html
主页.qml
Page {
anchors.fill: parent
header: PageHeader { ... }
// Some Items fill this page
BottomEdge{
id: myBottomEdge
height: parent.height - units.gu(20)
width: parent.width
anchors.bottom: parent.bottom
contentComponent: PageStack {
height: myBottomEdge.height
width: myBottomEdge.width
id: myPageStack
Component.onCompleted: {
push(Qt.resolvedUrl("StackPage.qml"),
{pageStackHeight: myBottomEdge.height})
}
}
}
}
StackPage.qml
Page {
id: myStackPage
anchors.fill: parent
property double pageStackHeight
Component.onCompleted: {
// Log Output 1
}
header: PageHeader{
title: i18n.tr('Add Workout')
trailingActionBar.actions: [
Action {
iconName: "next"
onTriggered: {
// Log Output 2
}
}
]
}
// Some Items fill this page
}
现在记录的 myStackPage 的宽度和高度值:
日志输出 1
qml: myStackPage Component.onCompleted
qml:myStackPage.height:440
qml:myStackPage.width:360
qml:pageStackHeight:440
正如您在此处看到的,高度和宽度的值是正确的。它与底部边缘的大小相同。这正是我想要的 myStackPage。
日志输出 2
qml: myStackPage 下一个动作触发
qml:myStackPage.height:0
qml:myStackPage.width:360
qml:pageStackHeight:440
正如您在记录的值中看到的那样,当我通过 PageHeader 中的“next”-Action 触发输出时,PageStack 上的页面以某种方式将其高度更改为 0。
是什么导致调整大小为0?出于绝望,我什至尝试将我的 BottomEdge 组件的高度作为属性 (pageStackheight) 传递给 myStackPage,并尝试将页面的高度设置为 pageStackHeight。但即使我这样做,myStackPage 的高度也会重置为 0,尽管属性 pageStackHeight 不是。
我在这里相对较新,所以请随时提出建议,使我的问题对读者更清楚。
先感谢您!