25 QFrame *f =
new QFrame();
27 QPalette
pal = palette();
28 pal.setBrush( backgroundRole(), pal.window() );
30 f->setAutoFillBackground(
true );
31 f->setFrameShape( QFrame::StyledPanel );
32 f->setFrameShadow( QFrame::Plain );
34 mLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
35 mLayout->setAlignment( Qt::AlignRight | Qt::AlignTop );
36 f->setLayout( mLayout );
38 QBoxLayout *topLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
39 topLayout->setContentsMargins( 0, 0, 0, 0 );
40 topLayout->addWidget( f );
41 setLayout( topLayout );
44 topLayout->setSizeConstraint( QLayout::SetFixedSize );
45 mLayout->setSizeConstraint( QLayout::SetFixedSize );
47 setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
53 QFrame *line =
nullptr;
54 if ( mWidgetList.count() > 0 )
56 line =
new QFrame(
this );
57 line->setFrameShadow( QFrame::Sunken );
58 line->setFrameShape( mLayoutHorizontal ? QFrame::VLine : QFrame::HLine );
59 mLayout->addWidget( line );
61 mLayout->addWidget( widget );
63 connect( widget, &QObject::destroyed,
this, &QgsUserInputWidget::widgetDestroyed );
65 mWidgetList.insert( widget, line );
72 void QgsUserInputWidget::widgetDestroyed( QObject *obj )
74 if ( obj->isWidgetType() )
76 QWidget *w = qobject_cast<QWidget *>( obj );
77 QMap<QWidget *, QFrame *>::iterator i = mWidgetList.find( w );
78 while ( i != mWidgetList.end() )
82 i.value()->deleteLater();
84 i = mWidgetList.erase( i );
87 if ( mWidgetList.count() == 0 )
93 void QgsUserInputWidget::setLayoutDirection( QBoxLayout::Direction direction )
95 mLayout->setDirection( direction );
97 bool horizontal = direction == QBoxLayout::LeftToRight || direction == QBoxLayout::RightToLeft;
98 QMap<QWidget *, QFrame *>::const_iterator i = mWidgetList.constBegin();
99 while ( i != mWidgetList.constEnd() )
103 i.value()->setFrameShape( horizontal ? QFrame::VLine : QFrame::HLine );
113 if ( mWidgetList.count() == 0 )