| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   19 #include <QDragEnterEvent> 
   26   setModel( mProxyModel );
 
   32   setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
 
   34   setAcceptDrops( 
true );
 
  100     setCurrentIndex( -1 );
 
  108     const QModelIndex proxyIdx = mProxyModel->mapFromSource( idx );
 
  109     if ( proxyIdx.isValid() )
 
  111       setCurrentIndex( proxyIdx.row() );
 
  116   setCurrentIndex( -1 );
 
  122   return layer( currentIndex() );
 
  127   const QModelIndex proxyIndex = mProxyModel->index( layerIndex, 0 );
 
  128   if ( !proxyIndex.isValid() )
 
  133   const QModelIndex index = mProxyModel->mapToSource( proxyIndex );
 
  134   if ( !index.isValid() )
 
  161   else if ( count() == 0 )
 
  167 QgsMapLayer *QgsMapLayerComboBox::compatibleMapLayerFromMimeData( 
const QMimeData *data )
 const 
  184   if ( !( event->possibleActions() & Qt::CopyAction ) )
 
  190   if ( compatibleMapLayerFromMimeData( event->mimeData() ) )
 
  193     event->setDropAction( Qt::CopyAction );
 
  220   if ( !( event->possibleActions() & Qt::CopyAction ) )
 
  226   if ( 
QgsMapLayer *
layer = compatibleMapLayerFromMimeData( event->mimeData() ) )
 
  229     setFocus( Qt::MouseFocusReason );
 
  230     event->setDropAction( Qt::CopyAction );
 
  245   QComboBox::paintEvent( e );
 
  246   if ( mDragActive || mHighlight )
 
  250     p.setPen( QPen( palette().highlight(), width ) );
 
  251     const QRect r = rect().adjusted( width, width, -width, -width );
 
  
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the combo box.
 
void setProject(QgsProject *project)
Sets the project from which map layers are shown.
 
void dropEvent(QDropEvent *event) override
 
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the model.
 
void dragEnterEvent(QDragEnterEvent *event) override
 
void setExcludedProviders(const QStringList &providers)
Sets a blocklist of data providers which should be excluded from the model.
 
QList< QgsMimeDataUtils::Uri > UriList
 
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 dragLeaveEvent(QDragLeaveEvent *event) override
 
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the combo box text.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the combobox.
 
bool acceptsLayer(QgsMapLayer *layer) const
Returns true if the proxy model accepts the specified map layer.
 
QgsMapLayerModel * sourceLayerModel() const
layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel
 
QgsMapLayer * currentLayer() const
Returns the current layer selected in the combo box.
 
QgsMapLayerComboBox(QWidget *parent=nullptr)
QgsMapLayerComboBox creates a combo box to display the list of layers (currently in the registry).
 
QStringList excludedProviders() const
Returns the blocklist of data providers which are excluded from the model.
 
QModelIndex indexFromLayer(QgsMapLayer *layer) const
indexFromLayer returns the model index for a given layer
 
void setProject(QgsProject *project)
Sets the project from which map layers are shown.
 
The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widget...
 
void setAdditionalLayers(const QList< QgsMapLayer * > &layers)
Sets a list of additional layers to include in the combobox.
 
QStringList additionalItems
 
QList< QgsMapLayer * > additionalLayers() const
Returns the list of additional layers added to the combobox.
 
void setAdditionalLayers(const QList< QgsMapLayer * > &layers)
Sets a list of additional layers to include in the model.
 
QgsMapLayer * layer(int layerIndex) const
Returns the layer currently shown at the specified index within the combo box.
 
QList< QgsMapLayer * > additionalLayers() const
Returns the list of additional layers added to the model.
 
static UriList decodeUriList(const QMimeData *data)
 
void setExcludedProviders(const QStringList &providers)
Sets a list of data providers which should be excluded from the combobox.
 
Base class for all map layer types. This is the base class for all map layer types (vector,...
 
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
 
void paintEvent(QPaintEvent *e) override
 
void setLayer(QgsMapLayer *layer)
setLayer set the current layer selected in the combo
 
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
 
QStringList excludedProviders
 
void setAllowEmptyLayer(bool allowEmpty, const QString &text=QString(), const QIcon &icon=QIcon())
Sets whether an optional empty layer ("not set") option is present in the model.