Skip to content

Commit dd54cf2

Browse files
committedApr 6, 2016
Better support for LabelOnTop in multicolumn attribute form layouts
1 parent 226339c commit dd54cf2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎src/gui/qgsattributeform.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,18 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
780780
else
781781
{
782782
QLabel* mypLabel = new QLabel( widgetInfo.labelText );
783-
if ( columnCount > 1 )
783+
if ( columnCount > 1 && !widgetInfo.labelOnTop )
784+
{
784785
mypLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
786+
}
785787

786788
if ( widgetInfo.labelOnTop )
787789
{
788-
gbLayout->addWidget( mypLabel, row, column, 1, 2 );
789-
++row;
790-
gbLayout->addWidget( widgetInfo.widget, row, column, 1, 2 );
790+
QVBoxLayout* c = new QVBoxLayout();
791+
mypLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
792+
c->layout()->addWidget( mypLabel );
793+
c->layout()->addWidget( widgetInfo.widget );
794+
gbLayout->addLayout( c, row, column, 1, 2 );
791795
column += 2;
792796
}
793797
else
@@ -805,7 +809,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
805809
}
806810
QWidget* spacer = new QWidget();
807811
spacer->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
808-
// gbLayout->addWidget( spacer, index, 0 );
812+
gbLayout->addWidget( spacer, ++row, 0 );
809813

810814
newWidgetInfo.labelText = QString::null;
811815
newWidgetInfo.labelOnTop = true;

0 commit comments

Comments
 (0)
Please sign in to comment.