3

I have created/designed an attribute form window in the Layer Properties - Attribute Form using "Drag and drop"-designer for a polygon shapefile.

UPDATE: If I use "Autogenerate", the Attribute form window is resizable.

However, in that case, I can not benefit from several columns leaving me with a lot of scrolling. I have compared the 2 different qml-files (one saved with "Drag and drop" and one saved with "Autogenerate"). But I'm not able to detect where/how/if it is possible to tell QGIS that the window should be resizable within the qml-file.

The number of fields (attributes) will differ for different shapefiles. It may be 10, it may be 50.

I have organized the attributes by collecting the Species into a Group Box called "Arter" with 4 columns. (It looks a little bit strange since the "default" qml-file was made with ALL species, but in most cases, 8-50 species occurs, and the columns are populated from the left and then downwards in QGIS)

enter image description here

Since the number of species present varies, the Attribute form window that appears when digitizing can get quite big, actually too big even if I set to 5 columns in the Group box "Arter". The Cancel and the OK button is not visible on the screen and I'm unable to resize the window.

enter image description here

Is it possible to:

  1. tell QGIS the attribute window should be resizable
  2. set the width of the Text Edit widget and the Range widget to reduce the width of the "columns" in the Group Box "Arter"

in the Attribute Form or in the qml-file?

E.g. somewhere near/in the qml-file:

    <attributeEditorContainer name="Arter" groupBox="1" visibilityExpressionEnabled="0" visibilityExpression="" showLabel="1" columnCount="5">

Or setting the width for TextEdit and Range?

The range is from 0-7 and the widget could be more narrow: one digit doesn't take much Space.

<field name="nye_arter">
  <editWidget type="TextEdit">
    <config>
      <Option type="Map">
        <Option value="false" name="IsMultiline" type="bool"/>
        <Option value="false" name="UseHtml" type="bool"/>
      </Option>
    </config>
  </editWidget>
</field>
<field name="Akeleie">
  <editWidget type="Range">
    <config>
      <Option type="Map">
        <Option value="true" name="AllowNull" type="bool"/>
        <Option value="7" name="Max" type="int"/>
        <Option value="1" name="Min" type="int"/>
        <Option value="0" name="Precision" type="int"/>
        <Option value="1" name="Step" type="int"/>
        <Option value="SpinBox" name="Style" type="QString"/>
      </Option>
    </config>
  </editWidget>
  • why not use custom.ui definition instead of drag&drop and QTDesigner to create a pleasent UI layout? – Luigi Pirelli Jun 27 '18 at 13:15
  • @LuigiPirelli: I'm not a programmer and don't know how. I just want to use the "built-in-possibilities" in QGIS. Since the autogenerated window is resizable, I hoped the drag-and-drop window would be likewise. – 9ls1 Jun 27 '18 at 13:29
  • old, but conceptually still valid nathanw.net/2012/03/30/custom-qgis-feature-forms-value-binding – Luigi Pirelli Jun 28 '18 at 14:08
  • 2
    Thanks. I'm aware of Nathans link and other sites. I have actually created a py and ui in an other project, but I find it time consuming since I'm self-taught in Python and depend on examples made by others. The number of TextEdit widgets will vary from one shapefile to another (each file represents a small area) depending on species occuring within the area, so I would need one py and one ui for each shapefile? With Autogenerate and Drag and drop only Fields (TextEdit-widgets) present in the area (shapefile) automatically appear. – 9ls1 Jun 28 '18 at 15:34
  • Sorry but seems you are describing a typical case where custom widget and custom py are necessary. Business logic can't be solved with a UI builder (well some logic can be added in the ui via QT Designer). BTW I would be happy to be in error. – Luigi Pirelli Jun 30 '18 at 18:38
3

I have found a solution. Through another project, I came across the same problem: the Attribute form window was too large for the tablet screen and the OK button would not be available. The soultion when using "Drag and drop"-designer is to put all attributes (fields) into a tab (or several). The tab(s) may then contain several attributes or groups of attributes. This results in a resizable tab within the Attribute form window where the OK button always is visible.

1) Add tab Registrer.

Add tab Registrer

2) Put all attributes into tab Registrer.

Put all attributes into tab Registrer

3) The tab is resizable within the Attribute form window.

The tab is resizable

  • Thanks for sharing your answer; I'm happy that you found an accessible solution to the many others (including myself) who can't "just" create a Python form, as if it were so easy... – she_weeds Sep 13 '18 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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