I've got a plugin where I load some layers. After the last layer loaded, I show the attribute table.

However, I would like to select the form view and not the table view (see image).

How can I do this in Python?

Attribute table layout options

1 Answer 1


On QGIS v.2.6 you can open the Attribute table in form view (attribute editor) mode, this way:

  1. Load a layer into QGIS and make it active (that is, click on its name in the ToC).
  2. Open the QGIS Python console.
  3. Paste the following code snippet there:

    from qgis.gui import QgsDualView
    dv = QgsDualView()
    dv.init( iface.activeLayer(), iface.mapCanvas() )
    dv.setView( QgsDualView.AttributeEditor )

And you get (yeah, I know it lacks the toolbar at the top, but that's the most you can get from PyQGIS :D) this:

enter image description here

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.