Skip to content
Permalink
Browse files
Virtual fields are not editable
  • Loading branch information
domi4484 committed Oct 28, 2021
1 parent 59fdd30 commit 0870a8c69ab5a06e873fc021a86b8b6dfea51199
Showing with 1 addition and 13 deletions.
  1. +1 −13 src/gui/qgsattributeform.cpp
@@ -594,24 +594,12 @@ void QgsAttributeForm::updateValuesDependenciesVirtualFields( const int originId

for ( int i = 0; i < dstVars.count(); i++ )
{
if ( !qgsVariantEqual( dstVars[i], srcVars[i] ) && srcVars[i].isValid() && fieldIsEditable( fieldIndexes[i] ) )
if ( !qgsVariantEqual( dstVars[i], srcVars[i] ) && srcVars[i].isValid() )
featureAttributes[fieldIndexes[i]] = srcVars[i];
}
}
updatedFeature.setAttributes( featureAttributes );

// If originIdx is a virtual field make sure it is up to date
{
QString expressionField = mLayer->expressionField( originIdx );
if ( ! expressionField.isEmpty() )
{
QgsExpressionContext context = createExpressionContext( updatedFeature );
QgsExpression exp( expressionField );
QVariant value = exp.evaluate( &context );
updatedFeature.setAttribute( originIdx, value );
}
}

// go through depending fields and update the virtual field with its expression
QList<QgsWidgetWrapper *> relevantWidgets = mVirtualFieldsDependencies.values( originIdx );
for ( QgsWidgetWrapper *ww : std::as_const( relevantWidgets ) )

0 comments on commit 0870a8c

Please sign in to comment.