Class: QgsRasterBandComboBox

A combobox widget which displays the bands present in a raster layer.

QgsRasterBandComboBox in the collapsed state

QgsRasterBandComboBox in the collapsed state

QgsRasterBandComboBox in the expanded state

QgsRasterBandComboBox in the expanded state

Class Hierarchy

Inheritance diagram of qgis.gui.QgsRasterBandComboBox

Base classes

QComboBox

QWidget

QObject

QPaintDevice

Methods

currentBand

Returns the current band number selected in the combobox, or -1 if no band is selected.

isShowingNotSetOption

Returns True if the combo box is showing the "not set" option.

layer

Returns the layer currently associated with the combobox.

setBand

Sets the current band number selected in the combobox.

setLayer

Sets the raster layer for which the bands are listed in the combobox.

setShowNotSetOption

Sets whether the combo box should show the "not set" option.

Static Methods

displayBandName

Returns a user-friendly band name for the specified band.

Signals

bandChanged

Emitted when the currently selected band changes.

class qgis.gui.QgsRasterBandComboBox[source]

Bases: QComboBox

__init__(parent: QWidget | None = None)

Constructor for QgsRasterBandComboBox.

Parameters:

parent (Optional[QWidget] = None)

signal bandChanged(band: int)[source]

Emitted when the currently selected band changes.

Parameters:

band (int)

currentBand(self) int[source]

Returns the current band number selected in the combobox, or -1 if no band is selected.

See also

setBand()

Return type:

int

static displayBandName(provider: QgsRasterDataProvider | None, band: int) str[source]

Returns a user-friendly band name for the specified band.

Parameters:
Return type:

str

isShowingNotSetOption(self) bool[source]

Returns True if the combo box is showing the “not set” option.

Return type:

bool

layer(self) QgsRasterLayer | None[source]

Returns the layer currently associated with the combobox.

See also

setLayer()

Return type:

Optional[QgsRasterLayer]

setBand(self, band: int)[source]

Sets the current band number selected in the combobox.

See also

band()

Parameters:

band (int)

setLayer(self, layer: QgsMapLayer | None)[source]

Sets the raster layer for which the bands are listed in the combobox. If no layer is set or a non-raster layer is set then the combobox will be empty.

See also

layer()

Parameters:

layer (Optional[QgsMapLayer])

setShowNotSetOption(self, show: bool, string: str | None = '')[source]

Sets whether the combo box should show the “not set” option. Optionally the built in “not set” text can be overridden by specifying a string.

Parameters:
  • show (bool)

  • string (Optional[str] = '')