Qt keyPress/keyRelease notify work differently on Vista and Linux



  • I found that the keyPress event is never fired until the key is actually released on Linux . This behavior is different on vista.

    The difference happens when I do the following sequence: 1) CTRL key down, 2) hold it for a while 3) release it.

    On Linux, nothing is printed out till the release.i.e. you'll not see anything till 3), then you'see "notify::KeyPressed" and "notify::KeyReleased".

    On Vista, after 1), you'll see "notify::KeyPressed", then in 2), you can detect that the CTRL is down with QApplication::keyboardModifier().testFlag(Qt::ControlModifier). then after 3), you'll see "notify::KeyReleased".

    I think what happens on vista is what I expected. How can I fix the problem on Linux and why it happens this way?

    Thanks for your help!

    Here is a piece of code from my application:

    @MyApplication::QApplication
    {
    bool notify(Object * receiver, QEvent * event) {
    try{
    if (event->type() == QEvent::KeyPress) {
    std::cout<<"notify::KeyPressed"<<endl;
    }

           if (event->type() == QEvent::KeyRelease) {
               std::cout<<"notify::KeyReleased"<<endl;
           }
    
    
            return QApplication::notify( receiver, event );
       }
       catch ( ... ) {
          std::cerr << "Unknown Exception caught: " << ends;
    
       }
       return false;
    
    }
    

    }@


Log in to reply
 

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