Hi all,
Can anybody help me to know how to capture keyboard input.
QKeyEvent class i refered. But i want to know how to initialize it to capture an event.
Plz help...
Mahe2310
Hi all,
Can anybody help me to know how to capture keyboard input.
QKeyEvent class i refered. But i want to know how to initialize it to capture an event.
Plz help...
Mahe2310
use eventFilter() or keyPressEvent()
a life without programming is like an empty bottle
hi,
I didn't get how this process is being taking place...
Can you provide me a sample program that takes a keybord input on the window like up arrow press and message "Up arrow Pressed"...
Plz do consider...
For Qt 3.3.x:
There is great example in the Documentation. U can simply use QWidget::keyPressEvent()
Qt Code:
{ switch ( tolower(k->ascii()) ) { case 'r': // reload pict->load( name ); update(); break; case 'q': // quit break; } }To copy to clipboard, switch view to plain text mode
Here: http://doc.trolltech.com/3.3/picture-example.html#x127
I am sailing with the cane...
hi,
I gone thru the codes you given and understood the concept...
Thank you...
Now i experienced a problem that all keys except arrow keys are detected by QKeyEvent...
Can you tell why arrow keys are not detected...
Or whether the arrow key press are not among QKeyEvent...
Help me plz...
Mahesh
Originally Posted by dec0ding
Can you show your code that is dealing with the key events?
If you are using ascii() for these keys it wont work since they don't have an ascii() representation, you should use the Qt::Key value.
I could receive the arrow press event but on enter press nothing is happening except a repeating ofOriginally Posted by high_flyer
other events (defined in the code).....
key_press is my global variable
void MyWidget::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Up) {
key_press = -1;
}am able to
else if(event->key() == Qt::Key_Down) {
key_press = 1;
}am able to
else if(event->key() == Qt::Key_Enter) {
key_press = 3; // But this part of the code is not reached on enter key press
}
else {
QWidget::keyPressEvent(event);
}
// other events....
}
Last edited by mahe2310; 16th February 2006 at 09:19. Reason: fail to include few ogf the statements ...
I had a similiar problem a day ago, i posted my solution in the end how to catch Tab, enter and space and so on.
http://www.qtcentre.org/forum/showthread.php?t=670
Originally Posted by lumber44
thanks lumber... That is a good one...
Mahe2310
Bookmarks