Skip to content

Commit ca6c5ba

Browse files
committed
Merge pull request #8464 from elpaso/bugfix-20455-value-relation-multiple-rules
Emit valueChanged when a widget value changes as a consequence of ano… Cherry picked from 798155c
1 parent ac6d8cd commit ca6c5ba

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/gui/editorwidgets/core/qgseditorwidgetwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void QgsEditorWidgetWrapper::setEnabled( bool enabled )
6868

6969
void QgsEditorWidgetWrapper::setFeature( const QgsFeature &feature )
7070
{
71-
mFormFeature = feature;
71+
setFormFeature( feature );
7272
setValue( feature.attribute( mFieldIdx ) );
7373
}
7474

src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ void QgsValueRelationWidgetWrapper::widgetValueChanged( const QString &attribute
212212
// Do nothing if the value has not changed
213213
if ( attributeChanged )
214214
{
215+
QVariant oldValue( value( ) );
215216
setFormFeatureAttribute( attribute, newValue );
216217
// Update combos if the value used in the filter expression has changed
217218
if ( QgsValueRelationFieldFormatter::expressionRequiresFormScope( mExpression )
@@ -220,6 +221,15 @@ void QgsValueRelationWidgetWrapper::widgetValueChanged( const QString &attribute
220221
populate();
221222
// Restore value
222223
setValue( value( ) );
224+
// If the value has changed as a result of another widget's value change,
225+
// we need to emit the signal to make sure other dependent widgets are
226+
// updated.
227+
if ( oldValue != value() && fieldIdx() < formFeature().fields().count() )
228+
{
229+
QString attributeName( formFeature().fields().names().at( fieldIdx() ) );
230+
setFormFeatureAttribute( attributeName, value( ) );
231+
emitValueChanged( );
232+
}
223233
}
224234
}
225235
}

0 commit comments

Comments
 (0)