better handling of finding the current item after removeing an item

This commit is contained in:
Uwe Rathmann 2021-01-13 17:50:16 +01:00
parent aa43b0bece
commit ed4066369a

View File

@ -269,8 +269,20 @@ void QskStackBox::removeItemInternal( int index, bool unparent )
m_data->items.removeAt( index );
if ( index <= m_data->currentIndex )
Q_EMIT currentIndexChanged( --m_data->currentIndex );
auto& currentIndex = m_data->currentIndex;
if ( index <= currentIndex )
{
currentIndex--;
if ( currentIndex < 0 && !m_data->items.isEmpty() )
currentIndex = 0;
if ( currentIndex >= 0 )
m_data->items[ currentIndex ]->setVisible( true );
Q_EMIT currentIndexChanged( currentIndex );
}
resetImplicitSize();
polish();