24 setModel( mProxyModel );
75 setCurrentIndex( -1 );
82 QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
83 if ( proxyIdx.isValid() )
85 setCurrentIndex( proxyIdx.row() );
90 setCurrentIndex( -1 );
96 return layer( currentIndex() );
101 const QModelIndex proxyIndex = mProxyModel->index( layerIndex, 0 );
102 if ( !proxyIndex.isValid() )
107 const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
108 if ( !index.isValid() )
135 else if ( count() == 0 )
QStringList excludedProviders() const
Returns the list of data providers which are excluded from the combobox.
QModelIndex indexFromLayer(QgsMapLayer *layer) const
indexFromLayer returns the model index for a given layer
Base class for all map layer types.
QStringList additionalItems
bool allowEmptyLayer() const
Returns true if the combo box allows the empty layer ("not set") choice.
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the combobox.
QStringList excludedProviders() const
Returns the list of data providers which are excluded from the model.
void layerChanged(QgsMapLayer *layer)
layerChanged this signal is emitted whenever the currently selected layer changes ...
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the combobox.
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the combo box...
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
void setAllowEmptyLayer(bool allowEmpty)
Sets whether an optional empty layer ("not set") option is present in the model.
QgsMapLayerComboBox(QWidget *parent=nullptr)
QgsMapLayerComboBox creates a combo box to display the list of layers (currently in the registry)...
void setAllowEmptyLayer(bool allowEmpty)
Sets whether an optional empty layer ("not set") option is shown in the combo box.
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the combo box text.
void setLayer(QgsMapLayer *layer)
setLayer set the current layer selected in the combo
bool showCrs() const
Returns true if the combo box shows the layer's CRS.
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the model.
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the model.
QgsMapLayer * layer(int layerIndex) const
Returns the layer currently shown at the specified index within the combo box.
QgsMapLayer * currentLayer() const
Returns the current layer selected in the combo box.