PDA

View Full Version : Not getting keyPressEvent in my class?



blue_sky
18th April 2014, 11:53
When windowdiplayed( show() ), without clicking the window I am not getting keyPressEvent(-)
void class::keyPressEvent( QKeyEvent *e ){
----
----
}
So is there any way to get the keyPressEvent() without clicking on my Dialog/Window.
Thanks in advance.

anda_skoa
18th April 2014, 13:35
A common pattern used for non-modal dialogs, especialy those which are kept around and re-shown later is this



dialog->show(); // show it if hidden
dialog->raise(); // move it on top of sibling windows
dialog->activateWindow(); // make it the active sub window


Cheers,
_

blue_sky
21st April 2014, 15:16
No. still not getting .Without clicking in the dialog, I am not getting key press event in that class. Any other suggestions.Thanks in advance..

A common pattern used for non-modal dialogs, especialy those which are kept around and re-shown later is this



dialog->show(); // show it if hidden
dialog->raise(); // move it on top of sibling windows
dialog->activateWindow(); // make it the active sub window


Cheers,
_

ChrisW67
21st April 2014, 22:02
So is there any way to get the keyPressEvent() without clicking on my Dialog/Window
Your operating system/window manager will only send key strokes to your application if it currently has focus. Your dialog will only received keystrokes destined for your application if it is the currently focussed window in your application. Clicking on the dialog gives it that focus, as does calling activateWindow().

Perhaps you need to describe what you are trying to achieve and/or provide a complete, minimal program that demonstrates the problem.

blue_sky
25th April 2014, 08:16
Yes after clicking, my class is getting key press events,But the same could not achieved by writing dialog->activateWindow(). Is there any way to get events without clicking?Thanks a lot for help.