Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Function Keys as Shortcut Sequences
QtWS25 Last Chance

Function Keys as Shortcut Sequences

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    twall
    wrote on last edited by
    #1

    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?

    A J.HilkJ 2 Replies Last reply
    0
    • T twall

      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?

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @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
      

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      T 1 Reply Last reply
      0
      • T twall

        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?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @twall
        I'm surprised that it works at all, the sequence for F-Keys should be 'F1' or 'F2' etc

        however 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")
            }
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        3
        • A ambershark

          @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
          
          T Offline
          T Offline
          twall
          wrote on last edited by twall
          #4

          @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.

          A 1 Reply Last reply
          0
          • T twall

            @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.

            A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            @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.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved