Qgis Combo Manager

QGIS Combo Manager is a python module to easily manage combo boxes for layer lists and field lists.

Quick start

QGIS Combo Manager is a python module to easily manage a combo box with a layer list and eventually relate it with one or several combos with list of corresponding fields.

The field combos are filled with the names of columns of the currently selected layer in the layer combo.

In your plugin, create first a LayerCombo:

from qgiscombomanager import *

self.layerComboManager = VectorLayerCombo(self.layerComboWidget)

Then, associates some FieldCombo:

self.myFieldComboManager = FieldCombo(self.myFieldComboManager, self.layerComboManager)

The managers (layer or field) must be saved as a class property (self.something), so the variable is not getting out of scope in python.

The classes offers some convenience methods: getLayer() and setLayer(layer), for layer combos, and getFieldName(), getFieldAlias(), getFieldIndex() for field combos.

Layer Combos

A combo box can be assigned to list the layers. Three classes are available:

LayerCombo(widget, initLayer="", options={}, layerType=None)
VectorLayerCombo(widget, initLayer="", options={})
RasterLayerCombo(widget, initLayer="", options={})

VectorLayerCombo and RasterLayerCombo are convenient classes which are calling the main LayerCombo class with the same parameters and specifying the layerType.

Options are listed hereunder, default values being listed first:

*used for vector layer combos

This class offer convenient methods:

The LayerCombo will also emit signals:

Field combos

A combo box can be assigned to list the fields related to a given VectorLayerCombo.

FieldCombo(widget, vectorLayerCombo, initField="", fieldType=None)

Options are listed hereunder, default values being listed first:

This class offer convenient methods:

The FieldCombo will also emit a signal:

Band combos

Similarly to field combos, a combo box can be assigned to list the bands related to a given RasterLayerCombo.

BandCombo(widget, rasterLayerCombo, initBand=None)

This class offer a convenient method:

The BandCombo will also emit a signal:

Using git submodules

To use this module you can easily copy the files and put them in your project. A more elegant way is to use git submodule. Hence, you can keep up with latest improvements. In you plugin directory, do

git submodule add git://github.com/3nids/qgiscombomanager.git

A folder qgiscombomanager will be added to your plugin directory. However, git only references the module, and you can git pull in this folder to get the last changes.