Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting Ctrl+[number] key presses on laptop keyboard

Getting Ctrl+[number] key presses on laptop keyboard

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.7k 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.
  • N Offline
    N Offline
    nowrep
    wrote on last edited by
    #1

    Hello,
    I need to catch Ctrl+[number] (= Ctrl + 1, Ctrl + 2, ...) key presses. I have no problems whatsoever to catch it on classic (on numeric keyboard) keyboard with
    @ QKeySequence("Ctrl+1") @
    but I just cannot catch it on laptops (with only two keys pressed).
    Of course it is possible to "emulate" this keypress by clicking Ctrl+Shift+1 on laptop keyboards, but I want to use it without that Shift.
    The main problem is, that on each locale, it is emiting different signals. For example, Ctrl + 2 will be Ctrl + ě on czech layout.
    Is there any way to do it?

    I hope you understand me, and thanks for any answer!

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Have you tried <code>QKeySequence(Qt::CTRL + Qt::Key_1)</code> or overriding one of the key events, for example QWidget::keyReleaseEvent()? <code>QKeySequence(const QString &)</code> is always subject to locales (use <code>QKeySequence(tr("Ctrl+1"))</code> instead).

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nowrep
        wrote on last edited by
        #3

        QKeySequence(Qt::CTRL + Qt::Key_1) is working only by pressing Ctrl+Shift+1
        Overriding key events has the same behaviour.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          Why do you have to press shift again?

          (On laptops I'm used to know the numeric keyboard is disabled until NumLock is selected. Once selected, the numeric keyboard behaves like an oridnary numeric keyboard).

          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