Nicer way of ensuring selected character is in view

This commit is contained in:
Nyall Dawson 2019-05-02 16:01:23 +10:00
parent c534f5f3ee
commit 57fa54763a

View File

@ -118,7 +118,9 @@ void CharacterWidget::setCharacter( QChar character )
{ {
QScrollArea *scrollArea = qobject_cast< QScrollArea *>( widget->parent() ); QScrollArea *scrollArea = qobject_cast< QScrollArea *>( widget->parent() );
if ( scrollArea && mLastKey < 65536 ) if ( scrollArea && mLastKey < 65536 )
scrollArea->verticalScrollBar()->setValue( mLastKey / mColumns * mSquareSize ); {
scrollArea->ensureVisible( 0, mLastKey / mColumns * mSquareSize );
}
} }
if ( changed ) if ( changed )
emit characterSelected( mLastKey ); emit characterSelected( mLastKey );