'QML Keyboard Shortcut Click Button
I am trying to add a keyboard shortcut to my QML but I am having a hard time getting it working without repeating logic. Below is the code,
Controls.Button {
id:sendAction
Shortcut {
sequence: "Ctrl+Return"
onActivated: parent.trigger()
}
onPressed: {call function}
}
If I repeat the calling of the function, the keyboard shortcut works but with parent.trigger() it fails with trigger isn't a property of the button. I have tried looking up what functions can be called in a shortcut to trigger the parent but the documentation is quite light. Essentially what I need though is what to add in to onActivated to trigger the onPressed without repeating the function call.
Solution 1:[1]
have you tried the pressed signal?
onActivated: parent.pressed()
https://doc.qt.io/qt-5/qml-qtquick-controls2-abstractbutton.html#pressed-signal
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | luffy |
