shifting the focus when removing the active focus item from the focus

tab chain
This commit is contained in:
Uwe Rathmann 2020-07-25 18:53:43 +02:00
parent 9bd3e608ba
commit 89cedda359

View File

@ -107,7 +107,20 @@ void QskControl::setFocusPolicy( Qt::FocusPolicy policy )
if ( policy != d->focusPolicy )
{
d->focusPolicy = ( policy & ~Qt::TabFocus );
Inherited::setActiveFocusOnTab( policy & Qt::TabFocus );
const bool tabFocus = policy & Qt::TabFocus;
if ( !tabFocus && window() )
{
// Removing the activeFocusItem from the focus tab chain is not possible
if ( window()->activeFocusItem() == this )
{
if ( auto focusItem = nextItemInFocusChain( true ) )
focusItem->setFocus( true );
}
}
Inherited::setActiveFocusOnTab( tabFocus );
Q_EMIT focusPolicyChanged();
}