@@ -401,7 +401,6 @@ void QgsCollapsibleGroupBoxBasic::updateStyle()
401401 mCollapseButton ->setStyleSheet ( ssd );
402402 if ( offsetLeft != 0 || offsetTopTri != 0 )
403403 mCollapseButton ->move ( offsetLeft, offsetTopTri );
404-
405404 setUpdatesEnabled ( true );
406405}
407406
@@ -443,59 +442,30 @@ void QgsCollapsibleGroupBoxBasic::setCollapsed( bool collapse )
443442
444443void QgsCollapsibleGroupBoxBasic::collapseExpandFixes ()
445444{
446- if ( QApplication::style ()->objectName ().contains ( " macintosh" ) )
447- {
448- // handle QPushButtons in form layouts that stay partly visible on collapse (Qt bug?)
449- // hide on collapse for fix, but only show buttons that were specifically hidden when expanding
450- // key hiding off of this group box's object name so it does not affect child group boxes
451- const QByteArray objKey = QString ( " CollGrpBxHiddenButton_%1" ).arg ( objectName () ).toUtf8 ();
452- const char * pbHideKey = objKey.constData ();
445+ // handle child widgets so they don't paint while hidden
446+ const char * hideKey = " CollGrpBxHide" ;
453447
454- // handle child group box widgets that don't hide their frames on collapse of parent
455- const char * gbHideKey = " CollGrpBxHideGrpBx" ;
456-
457- if ( mCollapsed )
448+ if ( mCollapsed )
449+ {
450+ Q_FOREACH ( QObject* child, children () )
458451 {
459- // first hide all child group boxes, regardless of whether they are collapsible
460- foreach ( QGroupBox* gbx, findChildren<QGroupBox *>() )
461- {
462- if ( gbx->isVisible () && !gbx->property ( gbHideKey ).isValid () )
463- {
464- gbx->setProperty ( gbHideKey, QVariant ( true ) );
465- gbx->hide ();
466- }
467- }
468-
469- // hide still visible push buttons belonging to this group box
470- foreach ( QPushButton* pBtn, findChildren<QPushButton *>() )
452+ QWidget* w = qobject_cast<QWidget*>( child );
453+ if ( w && w != mCollapseButton )
471454 {
472- if ( pBtn->isVisible () && !pBtn->property ( pbHideKey ).isValid () )
473- {
474- pBtn->setProperty ( pbHideKey, QVariant ( true ) );
475- pBtn->hide ();
476- }
455+ w->setProperty ( hideKey, true );
456+ w->hide ();
477457 }
478458 }
479- else // on expand
459+ }
460+ else // on expand
461+ {
462+ Q_FOREACH ( QObject* child, children () )
480463 {
481- // first show push buttons belonging to this group box
482- foreach ( QPushButton* pBtn, findChildren<QPushButton *>() )
464+ QWidget* w = qobject_cast<QWidget*>( child );
465+ if ( w && w != mCollapseButton )
483466 {
484- if ( pBtn->property ( pbHideKey ).isValid () ) // don't have to check bool value
485- {
486- pBtn->setProperty ( pbHideKey, QVariant () ); // remove property
487- pBtn->show ();
488- }
489- }
490-
491- // show all hidden child group boxes
492- foreach ( QGroupBox* gbx, findChildren<QGroupBox *>() )
493- {
494- if ( gbx->property ( gbHideKey ).isValid () ) // don't have to check bool value
495- {
496- gbx->setProperty ( gbHideKey, QVariant () ); // remove property
497- gbx->show ();
498- }
467+ if ( w->property ( hideKey ).toBool () )
468+ w->show ();
499469 }
500470 }
501471 }
0 commit comments