Function Keys as Shortcut Sequences
-
Hello, I'm working on an application that will be fully driven by the keyboard (in QML). This will be on an embedded device that has a keypad that uses the (linux) keyboard driver. However, there will be an option for the user to plug in a keyboard for themselves too. To prevent accidental keyboard button presses, I thought that I'd put the shortcuts that drive my program onto the function row. F1 through F15. I noticed that when I do:
Shortcut { id: f1 context: Qt.WindowShortcut sequence: 1 onActivated: { console.log("f1") } }
It works. However, when I use any other function key (say F2), the Shortcut does not register. What can I do to make it register?
-
Hello, I'm working on an application that will be fully driven by the keyboard (in QML). This will be on an embedded device that has a keypad that uses the (linux) keyboard driver. However, there will be an option for the user to plug in a keyboard for themselves too. To prevent accidental keyboard button presses, I thought that I'd put the shortcuts that drive my program onto the function row. F1 through F15. I noticed that when I do:
Shortcut { id: f1 context: Qt.WindowShortcut sequence: 1 onActivated: { console.log("f1") } }
It works. However, when I use any other function key (say F2), the Shortcut does not register. What can I do to make it register?
@twall Can we see the code for
Shortcut
? Your problem is more than likely in there.I'm not great with QML but from what I can see there is no QML Shortcut object. I could have missed it but even when I tried to duplicate your problem I get:
file:///home/mike/test.qml:4 Shortcut is not a type
-
Hello, I'm working on an application that will be fully driven by the keyboard (in QML). This will be on an embedded device that has a keypad that uses the (linux) keyboard driver. However, there will be an option for the user to plug in a keyboard for themselves too. To prevent accidental keyboard button presses, I thought that I'd put the shortcuts that drive my program onto the function row. F1 through F15. I noticed that when I do:
Shortcut { id: f1 context: Qt.WindowShortcut sequence: 1 onActivated: { console.log("f1") } }
It works. However, when I use any other function key (say F2), the Shortcut does not register. What can I do to make it register?
@twall
I'm surprised that it works at all, the sequence forF-Keys
should be'F1'
or'F2'
etchowever you can summ up different keys to the same onActivated action this way:
Shortcut{ sequence: "F1,F2,F3" onActivated: console.log("FKey 1 and 2 and 3 were pressed after each other") } //This one you're looking for Shortcut{ sequences: ["F1","F2", "F3"] onActivated: console.log("FKey 1 or 2 or 3 was pressed") }
-
@twall Can we see the code for
Shortcut
? Your problem is more than likely in there.I'm not great with QML but from what I can see there is no QML Shortcut object. I could have missed it but even when I tried to duplicate your problem I get:
file:///home/mike/test.qml:4 Shortcut is not a type
@ambershark https://doc.qt.io/qt-5.10/qml-qtquick-shortcut.html
It's a QtQuick 2.7 type.
@J-Hilk Thank you so much! I feel like a goof.
-
@ambershark https://doc.qt.io/qt-5.10/qml-qtquick-shortcut.html
It's a QtQuick 2.7 type.
@J-Hilk Thank you so much! I feel like a goof.
@twall said in Function Keys as Shortcut Sequences:
It's a QtQuick 2.7 type.
Lol yep, I missed it when I searched. And in my test I only used QtQuick 2.1.