I have a TabView. Each Tab is in the separate file (here for simplicity I composed all the code in one file). I'd like to launch some function using Enter key or a Button. All is ok when I click the Buttons. But when I press Enter, nothing happens (onTriggered event handler is never executed) and I also get an error:
QQuickAction::event: Ambiguous shortcut overload: Return
If I have only one Tab the problem does not occur and the onTriggered handler is correctly executed.
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
Item {
width: 640
height: 480
TabView {
id: tabView
currentIndex: 0
anchors.fill: parent
Layout.minimumWidth: 360
Layout.minimumHeight: 360
Layout.preferredWidth: 480
Layout.preferredHeight: 640
Tab {
id: tab1
active: true
title: "One"
Item {
id: item
x: 16
y: 8
width: 640
height: 480
Action {
id: calcDataAction
text: "Run"
shortcut: StandardKey.InsertParagraphSeparator
tooltip: "one"
onTriggered: {
console.log("one")
}
}
Button {
action: calcDataAction
id: calcButton
x: 20
y: 20
height: 40
width: 100
}
}
}
Tab {
id: tab2
active: true
title: "Two"
Item {
id: item2
x: 16
y: 8
width: 640
height: 480
Action {
id: calcDataAction2
text: "Run"
shortcut: StandardKey.InsertParagraphSeparator
tooltip: "two"
onTriggered: {
console.log("two")
}
}
Button {
action: calcDataAction2
id: calcButton2
x: 20
y: 20
height: 40
width: 100
}
}
}
}
}
How can I solve it?
As a workaround I could use the following shortcut binding in the Action :
shortcut: tab1.activeFocus ? StandardKey.InsertParagraphSeparator : ""
But the problem is that, first I need (don't know why) to click on all tabs' headers, before events could trigger...