Skip to content

Commit

Permalink
Better support for LabelOnTop in multicolumn attribute form layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 6, 2016
1 parent 226339c commit dd54cf2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -780,14 +780,18 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
else
{
QLabel* mypLabel = new QLabel( widgetInfo.labelText );
if ( columnCount > 1 )
if ( columnCount > 1 && !widgetInfo.labelOnTop )
{
mypLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
}

if ( widgetInfo.labelOnTop )
{
gbLayout->addWidget( mypLabel, row, column, 1, 2 );
++row;
gbLayout->addWidget( widgetInfo.widget, row, column, 1, 2 );
QVBoxLayout* c = new QVBoxLayout();
mypLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
c->layout()->addWidget( mypLabel );
c->layout()->addWidget( widgetInfo.widget );
gbLayout->addLayout( c, row, column, 1, 2 );
column += 2;
}
else
Expand All @@ -805,7 +809,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
}
QWidget* spacer = new QWidget();
spacer->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred );
// gbLayout->addWidget( spacer, index, 0 );
gbLayout->addWidget( spacer, ++row, 0 );

newWidgetInfo.labelText = QString::null;
newWidgetInfo.labelOnTop = true;
Expand Down

0 comments on commit dd54cf2

Please sign in to comment.