PDA

View Full Version : Print screen key in Qt windows



hanumanth
9th April 2010, 05:42
Hi ,
I am using Qt 4.5.0 in MSVisual Studio 2005.I need a scancode for all the keyboard keys and I used the following Qt events in my application to collect the scancodes for all the keys.
code A:
bool event(QEvent *event)// event handler
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
codevalue = keyEvent->nativeScanCode();
qDebug()<<"The scancode is "<<codevalue<<endl; //to print the scancode to the console.
}

Code B:
void keyPressEvent(QKeyEvent * keyEvent)
{
codevalue = keyEvent->nativeScanCode();
qDebug()<<"scancode is "<<codevalue<<endl;
}

In windows,using these functions I got the scancodes for all the keys except PrintScreen key. Please help me how do I get the Scancode for PrintScreen key in Windows.

Note:: In linux PrintScreen key has scancode integer value of 111.

Thanks in advance,
Hanumanth..

Lykurg
9th April 2010, 06:17
Check for Qt::Key_Print. Maybe the key event is catched by the os.

hanumanth
16th April 2010, 15:44
Thanks for the reply.. I tried that but it is not captured. I used eventFilter, accept(),grabKeyboard(),setFocus(),Key_Print to capture the Printscreen event, but none of them worked.

Please let me know if there is any special way of handling this Print screen key in Qt. Or Should I use X11 calls to suppress the PrintScreen key in SUSE.

Thanks,
Hanumanth..