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. Is the "?" keyboard input intercepted by Qt?
Forum Updated to NodeBB v4.3 + New Features

Is the "?" keyboard input intercepted by Qt?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    code_fodder
    wrote on last edited by
    #1

    I have a simple QMainWindow app which I use to process keyboard events.

    I have something very similar to this code cut-down version:

    @
    MainWindow::keyPressEvent(QKeyEvent *event)
    {
    qDebug() << "Key: " << event->key() << ", " << event->text() << endl;
    }
    @

    So, if I press "/" key and then release I get two events (one for the press and one for the release).
    If I press SHIFT and then "a" and then release "a" and then release SHIFT I get 4 events (two presses and two releases).

    However, my issue is that when I try to get a questionmark ("?") by pressing SHIFT and then pressing "/" (in UK keyboard the slash key is shared with questionmark) and then release both. I get two events only, one for the SHIFT press and one for the SHIFT release.

    This is the only key that I know of that I can't get, it appears that question mark seems to be intercepted by Qt and therefore I don't get the keypress.

    Can anyone explain this? Is it possible to get the "?" to work with Qt?

    Thanks,
    Fodder

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      something like that:

      @
      if(event->type() == QEvent::KeyPress)
      {
      QKeyEvent keyEvent = static_cast<QKeyEvent>(event);

          qDebug() << "modifier" << keyEvent->nativeModifiers();
      
          if(keyEvent->key() == Qt::Key_Slash &&  (QApplication::keyboardModifiers() == Qt::ShiftModifier))
          {
              qDebug() << "key press" << keyEvent->key();
          }
      

      }
      ...
      @

      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