25 QFrame *f =
new QFrame();
26 f->setObjectName( QStringLiteral(
"mUserInputContainer" ) );
28 QPalette
pal = palette();
29 pal.setBrush( backgroundRole(),
pal.window() );
31 f->setAutoFillBackground(
true );
32 f->setFrameShape( QFrame::StyledPanel );
33 f->setFrameShadow( QFrame::Plain );
35 mLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
36 mLayout->setAlignment( Qt::AlignRight | Qt::AlignTop );
37 f->setLayout( mLayout );
39 QBoxLayout *topLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
40 topLayout->setContentsMargins( 0, 0, 0, 0 );
41 topLayout->addWidget( f );
42 setLayout( topLayout );
45 topLayout->setSizeConstraint( QLayout::SetFixedSize );
46 mLayout->setSizeConstraint( QLayout::SetFixedSize );
48 setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
54 QFrame *line =
nullptr;
55 if ( mWidgetList.count() > 0 )
57 line =
new QFrame(
this );
58 line->setFrameShadow( QFrame::Sunken );
59 line->setFrameShape( mLayoutHorizontal ? QFrame::VLine : QFrame::HLine );
60 mLayout->addWidget( line );
62 mLayout->addWidget( widget );
64 connect( widget, &QObject::destroyed,
this, &QgsUserInputWidget::widgetDestroyed );
66 mWidgetList.insert( widget, line );
73void QgsUserInputWidget::widgetDestroyed( QObject *obj )
75 if ( obj->isWidgetType() )
77 QWidget *w = qobject_cast<QWidget *>( obj );
78 const auto it = mWidgetList.find( w );
79 if ( it != mWidgetList.end() )
81 if ( QFrame *frame = it.value() )
85 mWidgetList.erase( it );
88 if ( mWidgetList.count() == 0 )
96 mLayout->setDirection( direction );
98 const bool horizontal = direction == QBoxLayout::LeftToRight || direction == QBoxLayout::RightToLeft;
99 QMap<QWidget *, QFrame *>::const_iterator i = mWidgetList.constBegin();
100 while ( i != mWidgetList.constEnd() )
102 if (
auto *lValue = i.value() )
104 lValue->setFrameShape( horizontal ? QFrame::VLine : QFrame::HLine );
114 if ( mWidgetList.count() == 0 )