Class: QgsColorRampShaderWidget

It has 2 ways how to use it. For raster layers, raster data provider and band is assigned and the Quantile classification mode can be used and the LoadFromBandButton is visible.

The other mode is used to style mesh layer contours (scalar datasets)

Added in version 3.4.

QgsColorRampShaderWidget

QgsColorRampShaderWidget

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorRampShaderWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

classify

Executes the single band pseudo raster classification

initializeForUseWithRasterLayer

Allows quantile classification mode for raster layers

loadMinimumMaximumFromTree

Loads min and max values from color ramp tree

maximum

Gets max value

minimum

Gets min value

populateColormapTreeWidget

Populates color ramp tree from ramp items

setExtent

Sets extent, only when used for raster layer

setFromShader

Sets widget state from the color ramp shader

setMinimumMaximum

Sets min max

setMinimumMaximumAndClassify

Sets min max and classify color tree

setRasterBand

Sets raster band, only when used for raster layer

setRasterDataProvider

Associates raster with the widget, only when used for raster layer

shader

Returns shared function used in the renderer

Signals

classificationModeChanged

Classification mode changed

minimumMaximumChangedFromTree

Color ramp tree has changed

widgetChanged

Widget changed

class qgis.gui.QgsColorRampShaderWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

Creates new color ramp shader widget

Parameters:

parent (Optional[QWidget] = None)

signal classificationModeChanged(mode: Qgis.ShaderClassificationMethod)[source]

Classification mode changed

Parameters:

mode (Qgis.ShaderClassificationMethod)

classify(self)[source]

Executes the single band pseudo raster classification

initializeForUseWithRasterLayer(self)[source]

Allows quantile classification mode for raster layers

loadMinimumMaximumFromTree(self)[source]

Loads min and max values from color ramp tree

maximum(self) float[source]

Gets max value

Return type:

float

minimum(self) float[source]

Gets min value

Return type:

float

signal minimumMaximumChangedFromTree(minimum: float, maximum: float)[source]

Color ramp tree has changed

Parameters:
  • minimum (float)

  • maximum (float)

populateColormapTreeWidget(self, colorRampItems: Iterable[QgsColorRampShader.ColorRampItem])[source]

Populates color ramp tree from ramp items

Parameters:

colorRampItems (Iterable[QgsColorRampShader.ColorRampItem])

setExtent(self, extent: QgsRectangle)[source]

Sets extent, only when used for raster layer

Parameters:

extent (QgsRectangle)

setFromShader(self, colorRampShader: QgsColorRampShader)[source]

Sets widget state from the color ramp shader

Parameters:

colorRampShader (QgsColorRampShader)

setMinimumMaximum(self, minimum: float, maximum: float)[source]

Sets min max

Parameters:
  • minimum (float)

  • maximum (float)

setMinimumMaximumAndClassify(self, minimum: float, maximum: float)[source]

Sets min max and classify color tree

Parameters:
  • minimum (float)

  • maximum (float)

setRasterBand(self, band: int)[source]

Sets raster band, only when used for raster layer

Parameters:

band (int)

setRasterDataProvider(self, dp: QgsRasterDataProvider | None)[source]

Associates raster with the widget, only when used for raster layer

Parameters:

dp (Optional[QgsRasterDataProvider])

shader(self) QgsColorRampShader[source]

Returns shared function used in the renderer

Return type:

QgsColorRampShader

signal widgetChanged[source]

Widget changed