
Originally Posted by
Lykurg
in wave_1 hold a pointer to wave_2 and vice versa. Then use QWidget::keyPressEvent() and there callwave_X->setFocus().
Or use signal and slots instead of the pointers.
Hi, I have a CentralWidget containing the 2 widget.
I don't have to call setFocus from such container widget?
I wrote this code
void CentralWidget
::keyPressEvent( QKeyEvent*pe
) {
switch( pe->key() )
{
case Qt::Key_Tab:
{
// switch the focus
if( m_pWave2->hasFocus() )
{
m_pWave1->setFocus( Qt::TabFocusReason );
}
else if ( m_pWave1->hasFocus() )
{
m_pWave2->setFocus(Qt::TabFocusReason);
}
break;
}
default:
break;
}
}
void CentralWidget::keyPressEvent( QKeyEvent*pe )
{
switch( pe->key() )
{
case Qt::Key_Tab:
{
// switch the focus
if( m_pWave2->hasFocus() )
{
m_pWave1->setFocus( Qt::TabFocusReason );
}
else if ( m_pWave1->hasFocus() )
{
m_pWave2->setFocus(Qt::TabFocusReason);
}
break;
}
default:
QWidget::keyPressEvent(pe);
break;
}
}
To copy to clipboard, switch view to plain text mode
this can be ok?
Bookmarks