PDA

View Full Version : Keypressevent - CTRL Key_Enter



qtuser20
2nd March 2010, 22:02
Hi

I am using the following code in keypressevent() to catch CTRL+Enter and CTRL+Return keys.

I find that CTRL+Return works fine, however only the code for ctrl key is passed when i use ctrl+enter(numeric keypad).
What am i doing wrong here?

Thanks



if ((e->modifiers()==Qt::ControlModifier) && (e->key()==Qt::Key_Return || e->key()==Qt::Key_Enter|| e->key()==Qt::Key_Space) )
{
test;
}

Lesiok
3rd March 2010, 07:00
For Enetr from numeric pad You have :
e->modifiers()==(Qt::ControlModifier || Qt::KeypadModifier)
So Yours code must look like :
if ((e->modifiers() & Qt::ControlModifier) && (e->key()==Qt::Key_Return || e->key()==Qt::Key_Enter|| e->key()==Qt::Key_Space) )
{
test;
}

qtuser20
3rd March 2010, 20:47
Hi

Thanks for the reply, but it not work in my case.
When i debug i find that event->key() returns the key code for CONTROL key and not ENTER.
event->modifiers() returns the keypadModifier
Any suggestions?

Thanks