Qt keyPressEvent not called properly when HOLDING down specific keys (shift key)



  • Normally when the key is hold down the keyPressEvent function is called as often as @QApplication::keyboardInputInterval() @ is set to. However it does not work for keys like shift,ctrl or alt.

    this is executing properly:

    @
    void Renderer::keyPressEvent(QKeyEvent *event)
    {
    if(event->key() == Qt::Key_Escape) qDebug() << "executing";
    }
    @

    this is executed only once when the button is pressed:

    @
    void Renderer::keyPressEvent(QKeyEvent *event)
    {
    if(event->key() == Qt::Key_Shift) qDebug() << "executing";
    }
    @

    the only difference is Qt::Key_Shift and Qt::Key_Escape. Anyone know how to fix this?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It is not a bug, the shift key as well as the ctrl and meta keys are modifiers so they don't repeat


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.