@@ -434,7 +434,12 @@ void QgsCollapsibleGroupBoxBasic::setCollapsed( bool collapse )
434434 {
435435 // process events so entire widget is shown
436436 QApplication::processEvents ();
437+ mParentScrollArea ->setUpdatesEnabled ( false );
437438 mParentScrollArea ->ensureWidgetVisible ( this );
439+ // and then make sure the top of the widget is visible - otherwise tall group boxes
440+ // scroll to their centres, which is disorienting for users
441+ mParentScrollArea ->ensureWidgetVisible ( mCollapseButton , 0 , 5 );
442+ mParentScrollArea ->setUpdatesEnabled ( true );
438443 }
439444 // emit signal for connections using collapsed state
440445 emit collapsedStateChanged ( isCollapsed () );
@@ -447,7 +452,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
447452
448453 if ( mCollapsed )
449454 {
450- Q_FOREACH ( QObject* child, children () )
455+ Q_FOREACH ( QObject* child, children () )
451456 {
452457 QWidget* w = qobject_cast<QWidget*>( child );
453458 if ( w && w != mCollapseButton )
@@ -459,7 +464,7 @@ void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
459464 }
460465 else // on expand
461466 {
462- Q_FOREACH ( QObject* child, children () )
467+ Q_FOREACH ( QObject* child, children () )
463468 {
464469 QWidget* w = qobject_cast<QWidget*>( child );
465470 if ( w && w != mCollapseButton )
0 commit comments