-
-
Notifications
You must be signed in to change notification settings - Fork 57
QEP 409: Attribute Form QML Widget Editing Capabilities #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nirvn
wants to merge
1
commit into
qgis:master
Choose a base branch
from
nirvn:qml_editing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # QGIS Enhancement: Attribute Form QML Widget Editing Capabilities | ||
|
|
||
| **Date** 2026/02/01 | ||
|
|
||
| **Author** Mathieu Pellerin (@nirvn) | ||
|
|
||
| **Contact** mathieu@opengis.ch | ||
|
|
||
| **Version** QGIS 4.2 | ||
|
|
||
| # Summary | ||
|
|
||
| Since 2018, users have gained the ability to add QML widgets to enhance their | ||
| attribute forms. These widgets have so far been read-only and used to display | ||
| feature attributes through QML scenes utilizing QML items such as graphs. | ||
|
|
||
| While this is a great addition when using feature forms to read features, the | ||
| QML widgets could be even more useful if they would allow for feature | ||
| attribute editing. | ||
|
|
||
| ## Proposed Solution and Benefits | ||
|
|
||
| This QEP proposes the introduction of a new object accessible within the QML | ||
| widget’s scene with invokable functions to act as a bridge between the scene | ||
| within QML widget and its attribute form. The newly introduced object – injected | ||
| into the scene’s root context - will allow for accessing the attribute form | ||
| context and enable attribute editing of the attribute form’s current feature. | ||
|
|
||
| This additional ability for QML widgets can unlock a world of new possibilities | ||
| by allowing for QML components to drive the creation of new user interface to | ||
| manipulate feature attributes. | ||
|
|
||
| ### API Considerations | ||
|
|
||
| For QML widgets to be able to edit the attribute form’s current feature, the | ||
| `QgsWidgetWrapper` class will need to be tweaked to add a signal to handle | ||
| attribute value changes. | ||
|
|
||
| As for the QML widget itself, a new `QgsAttributeFormQmlWidgetBridge` object | ||
| will be injected into the root context of the QML scene that will offer a few | ||
| invokable functions and a context property to drive attribute editing. | ||
|
|
||
| ``` | ||
| class QgsAttributeFormQmlWidgetBridge : public QObject | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| Q_PROPERTY( QgsAttributeFormContext context READ context NOTIFY contextChanged ) | ||
|
|
||
| public: | ||
| Form() = default; | ||
| ~Form() = default; | ||
|
|
||
| QgsAttributeFormContext context() const; | ||
| void setContext( const QgsAttributeFormContext &context ); | ||
|
|
||
| Q_INVOKABLE setAttribute( const QString &name, const QVariant &value ); | ||
| } | ||
| ``` | ||
|
|
||
| The object itself will be able to be expanded in the future to add more | ||
| functionalities if need be. | ||
|
|
||
| Note that the `QgsAttributeFormContext` class is already a `Q_GADGET`, which | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it be able to provide default value and constraint information? |
||
| means the only work required on that front will be to expose some of its | ||
| properties as `Q_PROPERTY` for QML widgets to be able to receive contextual | ||
| awareness of its current mode, the current feature, the parent feature, etc. | ||
|
|
||
| ## Deliverables | ||
|
|
||
| A new `QgsAttributeFormQmlWidgetBridge` class which will act as the bridge | ||
| between the scene within the QML widget and its attribute form. | ||
|
|
||
| ### Affected Files | ||
|
|
||
| - qgsattributeform.cpp | ||
| - qgsattributeformcontext.h | ||
| - qgswidgetwrapper.cpp | ||
| - qgswidgetwrapper.h | ||
| - qgsqmlwidgetwrapper.cpp | ||
| - qgsqmlwidgetwrapper.h | ||
|
|
||
| ## Risks | ||
|
|
||
| None | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's
QgsAttributeEditorContextor am I mixing something up?