Unsolved Help connecting a menu item to a QML page
-
Hi,
I am a newbie so I apologize in advance if my question is obvious.
I want to create a menu with several itens that once triggered open an existent QML page, for example the page "Apresentacao". Why doesn't it works?
MenuBar {
Menu {
title: qsTr("A empresa")
Action { text: qsTr("Apresentação..."); onTriggered: Apresentacao } //The page Apresentacao exists in the same directory
Action { text: qsTr("Second Page") }
Action { text: qsTr("Third Page...") }
MenuSeparator { }
Action { text: qsTr("&Quit") }
}
I also have another question. How do I can select multiple pics so the user can view them in swipe mode?Thanks in advance.
-
@nunomcarv said in Help connecting a menu item to a QML page:
onTriggered: Apresentacao
That expression does not do anything. You need to use a
Loader
to load this page, or put it inStackView
and open correct index when the action is clicked. -
@sierdzio Hi,
I am still unable to solve this.
Can you provide an example.
Thanks. -
I've tried this, but still doesn't work:
MenuBar {
Menu { title: "File"
MenuItem {text: "Open";
Loader {
id: loader
focus: true
}MouseArea { anchors.fill: parent onClicked: { loader.source = "Apresentacao.qml" } } Keys.onPressed: { console.log("Captured:", event.text); } }
}
} -
Here is something:
Window { visible: true Menu { title: qsTr("A empresa") Action { text: qsTr("Apresentação..."); onTriggered: loader.source = "Apresentacao.qml" } } Loader { anchors.fill: parent is: loader } }