In my main application window (QMainWindow), I am capturing the keyPressEvent for all the Function keys. I am successfully capturing F1, F3-F12, but F2 will not cause a keyPressEvent. I have looked throughout my main window code and I am not using F2 for any other shortcut that I know of. The thing that really has me puzzled is that I am creating a second QMainWindow and capturing the F1-F12 keyPressEvents without any problem. Is there some default shortcut that uses F2 that I am missing? I have ensured that I am using accept( )/ignore( ) throughout the press event.
void MainWindow
::keyPressEvent( QKeyEvent *event
) {
//This line will print for every key other than F2
fprintf( stderr, "In MainWindow::keyPressEvent( QKeyEvent *event )" );
if( event->state( ) & Qt::ControlButton )
{
keySequence += tr( "Ctrl+" );
}
if( event->state( ) & Qt::ShiftButton )
{
keySequence += tr( "Shift+" );
}
if( event->state( ) & Qt::AltButton )
{
keySequence += tr( "Alt+" );
}
if( event->state( ) & Qt::MetaButton )
{
keySequence += tr( "Meta+" );
}
if( event->key( ) != Qt::Key_Control &&
event->key( ) != Qt::Key_Shift &&
event->key( ) != Qt::Key_Meta &&
event->key( ) != Qt::Key_Alt )
{
... continue building the keySequence and check against configuration file
}
event->ignore( );
void MainWindow::keyPressEvent( QKeyEvent *event )
{
//This line will print for every key other than F2
fprintf( stderr, "In MainWindow::keyPressEvent( QKeyEvent *event )" );
QString keySequence = "";
if( event->state( ) & Qt::ControlButton )
{
keySequence += tr( "Ctrl+" );
}
if( event->state( ) & Qt::ShiftButton )
{
keySequence += tr( "Shift+" );
}
if( event->state( ) & Qt::AltButton )
{
keySequence += tr( "Alt+" );
}
if( event->state( ) & Qt::MetaButton )
{
keySequence += tr( "Meta+" );
}
if( event->key( ) != Qt::Key_Control &&
event->key( ) != Qt::Key_Shift &&
event->key( ) != Qt::Key_Meta &&
event->key( ) != Qt::Key_Alt )
{
... continue building the keySequence and check against configuration file
}
event->ignore( );
To copy to clipboard, switch view to plain text mode
Bookmarks