Skip to content
Permalink
Browse files
[AttributeForm] respect size policy of embedded widgets (#45990)
* [AttributeForm] respect size policy of embedded widgets

This let widgets wich can make use of more vertical space grow
togheter with the form dialog

* Check for more not expanding policies
  • Loading branch information
domi4484 committed Nov 11, 2021
1 parent a2de61c commit 1e8f64dcf64fbc04ba474682b3c4fac65e5882b9
Showing with 12 additions and 2 deletions.
  1. +8 −1 src/gui/qgsattributeform.cpp
  2. +1 −1 src/gui/qgsattributeformeditorwidget.cpp
  3. +3 −0 src/gui/qgsattributeformwidget.cpp
@@ -1561,6 +1561,7 @@ void QgsAttributeForm::init()
int column = 0;
int columnCount = 1;
bool hasRootFields = false;
bool addSpacer = true;

const QList<QgsAttributeEditorElement *> tabs = mLayer->editFormConfig().tabs();

@@ -1640,6 +1641,12 @@ void QgsAttributeForm::init()

label->setBuddy( widgetInfo.widget );

// If at least one expanding widget is present do not add a spacer
if ( widgetInfo.widget->sizePolicy().verticalPolicy() != QSizePolicy::Fixed
&& widgetInfo.widget->sizePolicy().verticalPolicy() != QSizePolicy::Maximum
&& widgetInfo.widget->sizePolicy().verticalPolicy() != QSizePolicy::Preferred )
addSpacer = false;

if ( !widgetInfo.showLabel )
{
QVBoxLayout *c = new QVBoxLayout();
@@ -1690,7 +1697,7 @@ void QgsAttributeForm::init()
}
}

if ( hasRootFields )
if ( hasRootFields && addSpacer )
{
QSpacerItem *spacerItem = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
layout->addItem( spacerItem, row, 0 );
@@ -46,7 +46,7 @@ QgsAttributeFormEditorWidget::QgsAttributeFormEditorWidget( QgsEditorWidgetWrapp

mMultiEditButton->setField( mEditorWidget->field() );
mAggregateButton = new QgsAggregateToolButton();
mAggregateButton->setType( editorWidget->field().type() );
mAggregateButton->setType( mEditorWidget->field().type() );
connect( mAggregateButton, &QgsAggregateToolButton::aggregateChanged, this, &QgsAttributeFormEditorWidget::onAggregateChanged );

if ( mEditorWidget->widget() )
@@ -60,6 +60,9 @@ QgsAttributeFormWidget::QgsAttributeFormWidget( QgsWidgetWrapper *widget, QgsAtt

mEditPage->layout()->addWidget( mWidget->widget() );

// Respect size policy of embedded widget
setSizePolicy( mWidget->widget()->sizePolicy() );

updateWidgets();
}

0 comments on commit 1e8f64d

Please sign in to comment.