Skip to content

Commit 19e212c

Browse files
authoredOct 27, 2017
Merge pull request #5469 from m-kuhn/constraintsOnForms
[FEATURE] Show comments as tooltips on form
2 parents 68179e2 + 869fc60 commit 19e212c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
 

‎src/gui/qgsattributeform.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ void QgsAttributeForm::init()
11921192
tabWidget = nullptr;
11931193
WidgetInfo widgetInfo = createWidgetFromDef( widgDef, container, mLayer, mContext );
11941194
QLabel *label = new QLabel( widgetInfo.labelText );
1195+
label->setToolTip( QStringLiteral( "<b>%1</b><p>%2</p>" ).arg( widgetInfo.labelText, widgetInfo.hint ) );
11951196
if ( columnCount > 1 && !widgetInfo.labelOnTop )
11961197
{
11971198
label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
@@ -1277,6 +1278,7 @@ void QgsAttributeForm::init()
12771278

12781279
// This will also create the widget
12791280
QLabel *l = new QLabel( fieldName );
1281+
l->setToolTip( QStringLiteral( "<b>%1</b><p>%2</p>" ).arg( fieldName, field.comment() ) );
12801282
QSvgWidget *i = new QSvgWidget();
12811283
i->setFixedSize( 18, 18 );
12821284

@@ -1599,6 +1601,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
15991601

16001602
newWidgetInfo.labelOnTop = mLayer->editFormConfig().labelOnTop( fieldDef->idx() );
16011603
newWidgetInfo.labelText = mLayer->attributeDisplayName( fieldDef->idx() );
1604+
newWidgetInfo.hint = mLayer->fields().at( fieldDef->idx() ).comment();
16021605
newWidgetInfo.showLabel = widgetDef->showLabel();
16031606

16041607
break;
@@ -1687,6 +1690,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
16871690
else
16881691
{
16891692
QLabel *mypLabel = new QLabel( widgetInfo.labelText );
1693+
mypLabel->setToolTip( QStringLiteral( "<b>%1</b><p>%2</p>" ).arg( widgetInfo.labelText, widgetInfo.hint ) );
16901694
if ( columnCount > 1 && !widgetInfo.labelOnTop )
16911695
{
16921696
mypLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );

‎src/gui/qgsattributeform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
304304

305305
QWidget *widget = nullptr;
306306
QString labelText;
307+
QString hint;
307308
bool labelOnTop = false;
308309
bool labelAlignRight = false;
309310
bool showLabel = true;

0 commit comments

Comments
 (0)
Please sign in to comment.