mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
FieldExpressionWidget: add tooltip if expression is larger than widget
This commit is contained in:
parent
63af881a38
commit
f380df1cd7
@ -63,7 +63,7 @@ class QgsFieldExpressionWidget : QWidget
|
||||
//! when expression has been edited (finished) it will be added to the model
|
||||
void expressionEditingFinished();
|
||||
|
||||
void currentFieldChanged( int i = 0 );
|
||||
void currentFieldChanged();
|
||||
|
||||
/**
|
||||
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status
|
||||
|
@ -195,6 +195,18 @@ void QgsFieldExpressionWidget::currentFieldChanged( int i /* =0 */ )
|
||||
|
||||
bool isExpression, isValid;
|
||||
QString fieldName = currentField( &isExpression, &isValid );
|
||||
|
||||
// display tooltip if widget is shorter than expression
|
||||
QFontMetrics metrics( mCombo->lineEdit()->font() );
|
||||
if ( metrics.width( fieldName ) > mCombo->lineEdit()->width() )
|
||||
{
|
||||
mCombo->setToolTip( fieldName );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCombo->setToolTip( "" );
|
||||
}
|
||||
|
||||
emit fieldChanged( fieldName );
|
||||
emit fieldChanged( fieldName, isValid );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user