QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Properties | Friends | List of all members
QgsMapLayerComboBox Class Reference

The QgsMapLayerComboBox class is a combo box which displays the list of layers. More...

#include <qgsmaplayercombobox.h>

Inheritance diagram for QgsMapLayerComboBox:
Inheritance graph
[legend]

Public Slots

void setLayer (QgsMapLayer *layer)
 setLayer set the current layer selected in the combo
 

Signals

void layerChanged (QgsMapLayer *layer)
 Emitted whenever the currently selected layer changes.
 

Public Member Functions

 QgsMapLayerComboBox (QWidget *parent=nullptr)
 QgsMapLayerComboBox creates a combo box to display the list of layers (currently in the registry).
 
QStringList additionalItems () const
 Returns the list of additional (non map layer) items included at the end of the combo box.
 
QList< QgsMapLayer * > additionalLayers () const
 Returns the list of additional layers added to the combobox.
 
bool allowEmptyLayer () const
 Returns true if the combo box allows the empty layer ("not set") choice.
 
QgsMapLayercurrentLayer () const
 Returns the current layer selected in the combo box.
 
QList< QgsMapLayer * > exceptedLayerList () const
 returns the list of excepted layers
 
QStringList excludedProviders () const
 Returns the list of data providers which are excluded from the combobox.
 
Qgis::LayerFilters filters () const
 currently used filter on list layers
 
QgsMapLayerlayer (int layerIndex) const
 Returns the layer currently shown at the specified index within the combo box.
 
void setAdditionalItems (const QStringList &items)
 Sets a list of additional (non map layer) items to include at the end of the combobox.
 
void setAdditionalLayers (const QList< QgsMapLayer * > &layers)
 Sets a list of additional layers to include in the combobox.
 
void setAllowEmptyLayer (bool allowEmpty, const QString &text=QString(), const QIcon &icon=QIcon())
 Sets whether an optional empty layer ("not set") option is shown in the combo box.
 
void setExceptedLayerList (const QList< QgsMapLayer * > &layerList)
 except a list of layers not to be listed
 
void setExcludedProviders (const QStringList &providers)
 Sets a list of data providers which should be excluded from the combobox.
 
Q_DECL_DEPRECATED void setFilters (int filters)
 Filters according to layer type and/or geometry type.
 
void setFilters (Qgis::LayerFilters filters)
 Filters according to layer type and/or geometry type.
 
void setProject (QgsProject *project)
 Sets the project from which map layers are shown.
 
void setShowCrs (bool showCrs)
 Sets whether the CRS of layers is also included in the combo box text.
 
bool showCrs () const
 Returns true if the combo box shows the layer's CRS.
 

Protected Slots

void indexChanged (int i)
 
void rowsChanged ()
 

Protected Member Functions

void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
void paintEvent (QPaintEvent *e) override
 

Properties

bool allowEmptyLayer
 
QStringList excludedProviders
 
Qgis::LayerFilters filters
 
bool showCrs
 

Friends

class QgsProcessingMapLayerComboBox
 

Detailed Description

The QgsMapLayerComboBox class is a combo box which displays the list of layers.

Since
QGIS 2.3

Definition at line 34 of file qgsmaplayercombobox.h.

Constructor & Destructor Documentation

◆ QgsMapLayerComboBox()

QgsMapLayerComboBox::QgsMapLayerComboBox ( QWidget *  parent = nullptr)
explicit

QgsMapLayerComboBox creates a combo box to display the list of layers (currently in the registry).

The layers can be filtered and/or ordered.

Definition at line 23 of file qgsmaplayercombobox.cpp.

Member Function Documentation

◆ additionalItems()

QStringList QgsMapLayerComboBox::additionalItems ( ) const

Returns the list of additional (non map layer) items included at the end of the combo box.

See also
setAdditionalItems()
Since
QGIS 3.0

Definition at line 79 of file qgsmaplayercombobox.cpp.

◆ additionalLayers()

QList< QgsMapLayer * > QgsMapLayerComboBox::additionalLayers ( ) const

Returns the list of additional layers added to the combobox.

See also
setAdditionalLayers()
Since
QGIS 3.22

Definition at line 89 of file qgsmaplayercombobox.cpp.

◆ allowEmptyLayer()

bool QgsMapLayerComboBox::allowEmptyLayer ( ) const

Returns true if the combo box allows the empty layer ("not set") choice.

See also
setAllowEmptyLayer()
Since
QGIS 3.0

Definition at line 59 of file qgsmaplayercombobox.cpp.

◆ currentLayer()

QgsMapLayer * QgsMapLayerComboBox::currentLayer ( ) const

Returns the current layer selected in the combo box.

See also
layer

Definition at line 121 of file qgsmaplayercombobox.cpp.

◆ dragEnterEvent()

void QgsMapLayerComboBox::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 183 of file qgsmaplayercombobox.cpp.

◆ dragLeaveEvent()

void QgsMapLayerComboBox::dragLeaveEvent ( QDragLeaveEvent *  event)
overrideprotected

Definition at line 205 of file qgsmaplayercombobox.cpp.

◆ dropEvent()

void QgsMapLayerComboBox::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 219 of file qgsmaplayercombobox.cpp.

◆ exceptedLayerList()

QList< QgsMapLayer * > QgsMapLayerComboBox::exceptedLayerList ( ) const
inline

returns the list of excepted layers

Definition at line 68 of file qgsmaplayercombobox.h.

◆ excludedProviders()

QStringList QgsMapLayerComboBox::excludedProviders ( ) const

Returns the list of data providers which are excluded from the combobox.

See also
setExcludedProviders()
Since
QGIS 3.0

Definition at line 49 of file qgsmaplayercombobox.cpp.

◆ filters()

Qgis::LayerFilters QgsMapLayerComboBox::filters ( ) const
inline

currently used filter on list layers

Definition at line 62 of file qgsmaplayercombobox.h.

◆ indexChanged

void QgsMapLayerComboBox::indexChanged ( int  i)
protectedslot

Definition at line 148 of file qgsmaplayercombobox.cpp.

◆ layer()

QgsMapLayer * QgsMapLayerComboBox::layer ( int  layerIndex) const

Returns the layer currently shown at the specified index within the combo box.

Parameters
layerIndexposition of layer to return
See also
currentLayer
Since
QGIS 2.10

Definition at line 126 of file qgsmaplayercombobox.cpp.

◆ layerChanged

void QgsMapLayerComboBox::layerChanged ( QgsMapLayer layer)
signal

Emitted whenever the currently selected layer changes.

◆ paintEvent()

void QgsMapLayerComboBox::paintEvent ( QPaintEvent *  e)
overrideprotected

Definition at line 244 of file qgsmaplayercombobox.cpp.

◆ rowsChanged

void QgsMapLayerComboBox::rowsChanged ( )
protectedslot

Definition at line 155 of file qgsmaplayercombobox.cpp.

◆ setAdditionalItems()

void QgsMapLayerComboBox::setAdditionalItems ( const QStringList &  items)

Sets a list of additional (non map layer) items to include at the end of the combobox.

These may represent additional layers such as layers which are not included in the map layer registry, or paths to layers which have not yet been loaded into QGIS.

See also
additionalItems()
Since
QGIS 3.0

Definition at line 74 of file qgsmaplayercombobox.cpp.

◆ setAdditionalLayers()

void QgsMapLayerComboBox::setAdditionalLayers ( const QList< QgsMapLayer * > &  layers)

Sets a list of additional layers to include in the combobox.

This method allows adding additional layers, which are not part of a project's layers, into the combobox.

See also
additionalLayers()
Since
QGIS 3.22

Definition at line 84 of file qgsmaplayercombobox.cpp.

◆ setAllowEmptyLayer()

void QgsMapLayerComboBox::setAllowEmptyLayer ( bool  allowEmpty,
const QString &  text = QString(),
const QIcon &  icon = QIcon() 
)

Sets whether an optional empty layer ("not set") option is shown in the combo box.

Since QGIS 3.20, the optional text and icon arguments allows the text and icon for the empty layer item to be set.

See also
allowEmptyLayer()
Since
QGIS 3.0

Definition at line 54 of file qgsmaplayercombobox.cpp.

◆ setExceptedLayerList()

void QgsMapLayerComboBox::setExceptedLayerList ( const QList< QgsMapLayer * > &  layerList)
inline

except a list of layers not to be listed

Definition at line 65 of file qgsmaplayercombobox.h.

◆ setExcludedProviders()

void QgsMapLayerComboBox::setExcludedProviders ( const QStringList &  providers)

Sets a list of data providers which should be excluded from the combobox.

See also
excludedProviders()
Since
QGIS 3.0

Definition at line 38 of file qgsmaplayercombobox.cpp.

◆ setFilters() [1/2]

Q_DECL_DEPRECATED void QgsMapLayerComboBox::setFilters ( int  filters)
inline

Filters according to layer type and/or geometry type.

Note
for API compatibility
Since
QGIS 3.34
Deprecated:
since QGIS 3.34 use the flag signature instead

Definition at line 59 of file qgsmaplayercombobox.h.

◆ setFilters() [2/2]

void QgsMapLayerComboBox::setFilters ( Qgis::LayerFilters  filters)
inline

Filters according to layer type and/or geometry type.

Definition at line 51 of file qgsmaplayercombobox.h.

◆ setLayer

void QgsMapLayerComboBox::setLayer ( QgsMapLayer layer)
slot

setLayer set the current layer selected in the combo

Definition at line 94 of file qgsmaplayercombobox.cpp.

◆ setProject()

void QgsMapLayerComboBox::setProject ( QgsProject project)

Sets the project from which map layers are shown.

If project is nullptr then QgsProject::instance() will be used.

Since
QGIS 3.24

Definition at line 43 of file qgsmaplayercombobox.cpp.

◆ setShowCrs()

void QgsMapLayerComboBox::setShowCrs ( bool  showCrs)

Sets whether the CRS of layers is also included in the combo box text.

See also
showCrs()
Since
QGIS 3.0

Definition at line 64 of file qgsmaplayercombobox.cpp.

◆ showCrs()

bool QgsMapLayerComboBox::showCrs ( ) const

Returns true if the combo box shows the layer's CRS.

See also
setShowCrs()
Since
QGIS 3.0

Definition at line 69 of file qgsmaplayercombobox.cpp.

Friends And Related Symbol Documentation

◆ QgsProcessingMapLayerComboBox

friend class QgsProcessingMapLayerComboBox
friend

Definition at line 204 of file qgsmaplayercombobox.h.

Property Documentation

◆ allowEmptyLayer

bool QgsMapLayerComboBox::allowEmptyLayer
readwrite

Definition at line 38 of file qgsmaplayercombobox.h.

◆ excludedProviders

QStringList QgsMapLayerComboBox::excludedProviders
readwrite

Definition at line 40 of file qgsmaplayercombobox.h.

◆ filters

Qgis::LayerFilters QgsMapLayerComboBox::filters
readwrite

Definition at line 37 of file qgsmaplayercombobox.h.

◆ showCrs

bool QgsMapLayerComboBox::showCrs
readwrite

Definition at line 39 of file qgsmaplayercombobox.h.


The documentation for this class was generated from the following files: