2

We create layers and for some we then also create attribute forms to handle automatic default values, unique values and value maps among other things. But when we add the same shape layer to a new project file only the basic shape attributes are maintained.

The same happens when we package projects with QPackage. All attribute form functions need to be remade in the project we just packed to be sent.

Is there a way to "attach" attribute forms to shape layers?

2 Answers 2

3

You can export the layer QML and save it to a file having the same filename as your shapefile. Its content will be automatically loaded when you add the shapefile to a project.

Right click the layer, go to export, then save as QGIS Layer Style File use the same name as your Shapefile (so mylayer.shp -> mylayer.qml), in the same folder.

Select what to export, field being required for default values (you can check all boxes if you want)

enter image description here

0

You can create a custom UI form and set your attribute editor layout to load it from the ui file.

enter image description here

You can also save your layer style as a qml which will save the ui editor form also

enter image description here

So all you have to do is load a qml file on your layer and everything will be setup (styles and attribute form), you can do it thanks to the above highlighted button

or programmatically :

(QgsVectorLayer)layer.loadNamedStyle("path_to_qml.qml")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.