@@ -1204,7 +1204,7 @@ void QgsAttributeForm::init()
1204
1204
tabWidget = nullptr ;
1205
1205
WidgetInfo widgetInfo = createWidgetFromDef ( widgDef, container, mLayer , mContext );
1206
1206
QLabel *label = new QLabel ( widgetInfo.labelText );
1207
- label->setToolTip ( QStringLiteral ( " <b>%1</b><p>%2</p> " ). arg ( widgetInfo.labelText , widgetInfo. hint ) );
1207
+ label->setToolTip ( widgetInfo.toolTip );
1208
1208
if ( columnCount > 1 && !widgetInfo.labelOnTop )
1209
1209
{
1210
1210
label->setAlignment ( Qt::AlignRight | Qt::AlignVCenter );
@@ -1283,6 +1283,8 @@ void QgsAttributeForm::init()
1283
1283
1284
1284
// show attribute alias if available
1285
1285
QString fieldName = mLayer ->attributeDisplayName ( idx );
1286
+ QString labelText = fieldName;
1287
+ labelText.replace ( ' &' , QStringLiteral ( " &&" ) ); // need to escape '&' or they'll be replace by _ in the label text
1286
1288
1287
1289
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry ()->findBest ( mLayer , field.name () );
1288
1290
@@ -1292,7 +1294,7 @@ void QgsAttributeForm::init()
1292
1294
bool labelOnTop = mLayer ->editFormConfig ().labelOnTop ( idx );
1293
1295
1294
1296
// This will also create the widget
1295
- QLabel *l = new QLabel ( fieldName );
1297
+ QLabel *l = new QLabel ( labelText );
1296
1298
l->setToolTip ( QStringLiteral ( " <b>%1</b><p>%2</p>" ).arg ( fieldName, field.comment () ) );
1297
1299
QSvgWidget *i = new QSvgWidget ();
1298
1300
i->setFixedSize ( 18 , 18 );
@@ -1625,6 +1627,8 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
1625
1627
1626
1628
newWidgetInfo.labelOnTop = mLayer ->editFormConfig ().labelOnTop ( fieldDef->idx () );
1627
1629
newWidgetInfo.labelText = mLayer ->attributeDisplayName ( fieldDef->idx () );
1630
+ newWidgetInfo.labelText .replace ( ' &' , QStringLiteral ( " &&" ) ); // need to escape '&' or they'll be replace by _ in the label text
1631
+ newWidgetInfo.toolTip = QStringLiteral ( " <b>%1</b><p>%2</p>" ).arg ( mLayer ->attributeDisplayName ( fieldDef->idx () ), newWidgetInfo.hint );
1628
1632
newWidgetInfo.showLabel = widgetDef->showLabel ();
1629
1633
1630
1634
break ;
@@ -1719,7 +1723,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
1719
1723
else
1720
1724
{
1721
1725
QLabel *mypLabel = new QLabel ( widgetInfo.labelText );
1722
- mypLabel->setToolTip ( QStringLiteral ( " <b>%1</b><p>%2</p> " ). arg ( widgetInfo.labelText , widgetInfo. hint ) );
1726
+ mypLabel->setToolTip ( widgetInfo.toolTip );
1723
1727
if ( columnCount > 1 && !widgetInfo.labelOnTop )
1724
1728
{
1725
1729
mypLabel->setAlignment ( Qt::AlignRight | Qt::AlignVCenter );
0 commit comments