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 )
bool showCrs() const
Returns true if the combo box shows the layer's CRS.
Base class for all map layer types.
QStringList additionalItems
QgsMapLayer * currentLayer() const
Returns the current layer selected in the combo box.
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the combobox.
QgsMapLayer * layer(int layerIndex) const
Returns the layer currently shown at the specified index within the combo box.
QModelIndex indexFromLayer(QgsMapLayer *layer) const
indexFromLayer returns the model index for a given layer
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.
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
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.
bool allowEmptyLayer() const
Returns true if the combo box allows the empty layer ("not set") choice.
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the combo box text.
QStringList excludedProviders() const
Returns the list of data providers which are excluded from the combobox.
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the combo box...
void setLayer(QgsMapLayer *layer)
setLayer set the current layer selected in the combo
void setExcludedProviders(const QStringList &providers)
Sets a blacklist 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.
QStringList excludedProviders() const
Returns the blacklist of data providers which are excluded from the model.