I have a dialog in my main.qml file the problem is that when I click menu to open dialog, after closing the dialog, Shortcut
don't work any more.
main.qml
ApplicationWindow {
id:mainWindow
Shortcut {
id:backShortcut
sequences: ["Esc", "Back"]
onActivated: {
console.log("Back In MainPage")
if(sv.depth>1)
{
sv.pop();
}
else if(drawer.visible){
drawer.close();
}
else{
exitDialog.open();
}
}
}
MenuItem{
contentItem: Text {
text: qsTr("Open Dialog")
}
onClicked: {
var c= myDialogCom.createObject(mainWindow);
c.open();
}
}
Component{
id:myDialogCom
MyDialog{
}
}
}
MyDialog.qml
Dialog {
id: root
parent: Overlay.overlay
x:0
height: mainWindow.height
width:mainWindow.width
header: ToolBar{
}
StackView{
}
}
Edit
I want to mention that I have summarized my questions for a faster understanding.But I had multiple Shortcut
in diffrent pages like:(ChatsPage.qm and ChatPage.qml and main.qml) but tried to question be simple,So I just said Shortcut
in just main.qml
becuase the problem is there yet
I changed context
property of Shortcut
to Qt.ApplicationShortcut
.Now It works.But I don't know why :> ,tanks if every body explain
Shortcut {
id:backShortcut
sequences: ["Esc", "Back"]
context: Qt.ApplicationShortcut
onActivated: {
console.log("Back In MainPage")
if(sv.depth>1)
{
sv.pop();
}
else if(drawer.visible){
drawer.close();
}
else{
exitDialog.open();
}
}
}