qml Stackview:弹出另一个文件中的页面
qml Stackview: pop a page which is in another file
我的问题是,我无法从堆栈中弹出 () 页面。
让我稍微解释一下:
我有一个显示几个项目的页面
每个项目都有一个按钮,它会在堆栈视图顶部打开一个新页面,我可以在其中编辑我的项目。
这个 EditPage 有一个关闭按钮 - 应该:是的,你明白了:关闭页面 xD
这意味着我要从堆栈中弹出页面
MainView.qml
// ...
StackView {
id: _myStack
initialItem: _myView
GridView {
id: _myView
model: // comes from c++
delegate: MyItem{}
}
}
MyItem.qml
Item{
id: _myItem
Button{
id: _buttonEdit
text: "Edit"
onClicked{
_stackview.push("../components/Edit.qml, {some properties I pass through}, MainView.Immediate)
// Edit.qml is in another folder, import is done
}
}
}
Edit.qml
Page{
id: _editPage
// some code
Button {
id: _closeButton
onClicked{
//
// here I want to pop this window out of the stack (it is the top item on the stack)
// _myStack.pop() doesn't work - because _myStack is not visible
}
}
我能做什么?我已经在 Edit.qml 中尝试过这个:有点我卡在了这一点上 -
在 MyItem.qml 或?
中绑定信号的位置
Page{
id: _editPage
signal closeEditPage
Button {
id: _closeButton
onClicked{
closeEditPage()
}
}
重新绑定附件 属性 StackView.view 以便于访问。
Page{
id: _editPage
property StackView _myStack: StackView.view
Button {
id: _closeButton
onClicked{
_myStack.pop()
}
}
我的问题是,我无法从堆栈中弹出 () 页面。 让我稍微解释一下:
我有一个显示几个项目的页面 每个项目都有一个按钮,它会在堆栈视图顶部打开一个新页面,我可以在其中编辑我的项目。 这个 EditPage 有一个关闭按钮 - 应该:是的,你明白了:关闭页面 xD
这意味着我要从堆栈中弹出页面
MainView.qml
// ...
StackView {
id: _myStack
initialItem: _myView
GridView {
id: _myView
model: // comes from c++
delegate: MyItem{}
}
}
MyItem.qml
Item{
id: _myItem
Button{
id: _buttonEdit
text: "Edit"
onClicked{
_stackview.push("../components/Edit.qml, {some properties I pass through}, MainView.Immediate)
// Edit.qml is in another folder, import is done
}
}
}
Edit.qml
Page{
id: _editPage
// some code
Button {
id: _closeButton
onClicked{
//
// here I want to pop this window out of the stack (it is the top item on the stack)
// _myStack.pop() doesn't work - because _myStack is not visible
}
}
我能做什么?我已经在 Edit.qml 中尝试过这个:有点我卡在了这一点上 - 在 MyItem.qml 或?
中绑定信号的位置Page{
id: _editPage
signal closeEditPage
Button {
id: _closeButton
onClicked{
closeEditPage()
}
}
重新绑定附件 属性 StackView.view 以便于访问。
Page{
id: _editPage
property StackView _myStack: StackView.view
Button {
id: _closeButton
onClicked{
_myStack.pop()
}
}