Skip to content

"Reuse last entered value" not applied when using PyQGIS #64655

Description

@Skipper-is

What is the bug or the crash?

Adding a new feature using PyQGIS - does not apply the "Reuse last entered value" - either from a feature created using pyqgis, or a feature created using the built in digitisation tools.

Steps to reproduce the issue

  1. Create a vector layer, (point in this case), with an attribute. Set the attribute form to "Reuse last entered value" in the attribute form settings. (also added a default value attribute to test that functionality also works)
  2. Add a feature using
geometry = QgsGeometry.fromPointXY(QgsPointXY(x, y))
            feat = QgsVectorLayerUtils.createFeature(layer, geometry, {}, layer.createExpressionContext() )

  1. Default value applied to that one, entered a value for the "reuse value" attribute.
  2. Add another feature, "reused value" is not applied to that attribute in the 2nd feature.

Versions

QGIS version3.40.11-Bratislava
QGIS code revisiondf059ed19c
 
Libraries
Qt version5.15.13
Python version3.12.11
GDAL version3.11.3 (Compiled)
3.11.4 (Running) — Eganville
PROJ version9.6.2 (Compiled)
9.7.0 (Running)
EPSG Registry database versionv12.022 (2025-08-30)
GEOS version3.13.1-CAPI-1.19.2
SQLite version3.50.4
PDAL version2.9.0
PostgreSQL client versionunknown
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 10 Version 2009
 
Active Python plugins
AnotherDXF2Shape1.3.2
Auto_save1.0
changeDataSource3.1
e_tracability0.7
FreehandRasterGeoreferencer0.8.3
html_table_exporter0.2.0
magic_map_loader1.2
quick_map_services1.1.0
slyr_community6.0.0
splitmultipart1.0.0
StreetView3.3
theme_manager1.0
TomBio3.4.4
what3words4.4
db_manager0.1.20
grassprovider2.12.99
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEither a bug report, or a bug fix. Let's hope for the latter!PyQGISRelated to the PyQGIS API

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions