Hi all,
I want to send a KeyDown message to the desktop widget which i got through QApplication::desktop(). Here is the code snippet:



// Also tried with - Qt::Key_SysReq

QKeyEvent keydownEvent(QEvent::KeyPress, Qt::Key_Print, Qt::AltModifier);
QDesktopWidget * desktopWidget = qApp->desktop();

qApp->sendEvent(desktopWidget, &keydownEvent);

bool bDownAccepted = keydownEvent.isAccepted();
QKeyEvent keyupEvent(QEvent::KeyRelease, Qt::Key_Print, Qt::AltModifier);
QApplication::sendEvent(desktopWidget, &keyupEvent);
bool bUpAccepted = keyupEvent.isAccepted();



Here my assumption was that this code should send an "Alt + PrintScreen" button press to the desktop widget which in effect should dump the "active window image" to the ClipBoard. But it is not happening in my case.
There is nothing copied to the ClipBoard and also bDownAccepted , bUpAccepted value is always false which means that DesktopWidget is not accepting the event.


My aim is just to capture the image of active window on the screen using QT.

can anybody tell whats wrong with the above code.
Any help would be appreciated.

Thnx in advance.

Shalabh