[Qt-interest] Qkey Press Event

Raphael Meloni raphael.meloni at gmail.com
Tue Jul 14 04:04:30 CEST 2009


A widget must accept focus initially and have focus in order to receive 
a key release event.

You can use grabKeyboard (), if only one widget get a key event.


if(event->key() == Qt::Key_5)
{
	QMessageBox::information(0,"",QString("Numer Key"));
}
event->accept();

Yuvaraj R escreveu:
> Hi All
>  
>   My program is detecting thre Enter key only from keyboard..
>  
> I am trying with
>  
> void MainWindow::keyPressEvent(QKeyEvent *event)
> 
> {
> 
> if(event->key() == Qt::Key_5)
> 
> {
> 
> QMessageBox::information(0,"",QString("Numer Key"));
> 
> }
> 
> }
> 
>  
> 
> this one is not detecting the number key five.
> 
> I want use only number keys..
> 
>  
> 
>  
> 
> what mistake i have done...
> 
>  
> 
> Any Idea ..
> 
>  
> 
> Advance Thanks
> 
>  
> 
>  
> 
> Yuvaraj R
> 



More information about the Qt-interest-old mailing list