Skip To Content ArcGIS for Developers Sign In Dashboard

LayerListModel Class

(Esri::ArcGISRuntime::LayerListModel)

A list model storing a list of layers available in a map. More...

Header: #include <LayerListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<Layer *>

Public Types

enum LayerRoles { LayerNameRole, LayerDescriptionRole, LayerVisibleRole, LayerCanChangeVisibility, ..., LayerOpacityRole }

Public Functions

~LayerListModel()
void append(Layer *layer)
Layer *at(int index) const
void clear()
bool contains(Layer *layer) const
Layer *first() const
int indexOf(Layer *layer) const
void insert(int index, Layer *layer)
bool isEmpty() const
Layer *last() const
void move(int from, int to)
void removeAt(int index)
void removeOne(Layer *layer)
int size() const

Reimplemented Public Functions

virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const

Signals

void errorOccurred(Esri::ArcGISRuntime::Error error)
void layerAdded(int index)
void layerRemoved(int index)

Additional Inherited Members

Detailed Description

A list model storing a list of layers available in a map.

Modifying this model (adding, removing, moving) will update the layers available in the map.

The model returns data for the following roles:

RoleTypeDescription
nameQStringThe layer's name.
descriptionQStringThe layer's description.
layerVisibleboolWhether the layer is visible.
canChangeVisibilityboolWhether the layer's visibility can be changed.
loadErrorErrorTypeThe layer's load error type.
loadStatusLoadStatusThe layer's load status.
layerTypeLayerTypeThe layer's type.
attributionQStringThe layer's attribution if any is available.
showInLegendboolWhether the layer will be shown in the legend.
layerIdQStringThe layer's ID specified in the web map JSON.
minScaledoubleThe minimum scale at which the layer displays.
maxScaledoubleThe maximum scale at which the layer displays.
layerOpacityfloatThe opacity of the layer between 0.0 and 1.0.
Map *map = new Map(BasemapType::NationalGeographic, -117, 34, 15, this);
ServiceFeatureTable *featureTable = new ServiceFeatureTable(featureServiceUrl, this);
FeatureLayer *featureLayer = new FeatureLayer(featureTable, this);
LayerListModel* llModel = map->operationalLayers();
llModel->insert(1,featureLayer);

Member Type Documentation

enum LayerListModel::LayerRoles

This enum specifies the custom roles which can be used with LayerListModel::data.

ConstantValueDescription
Esri::ArcGISRuntime::LayerListModel::LayerNameRoleQt::UserRole + 1The layer's name.
Esri::ArcGISRuntime::LayerListModel::LayerDescriptionRoleQt::UserRole + 2The layer's description.
Esri::ArcGISRuntime::LayerListModel::LayerVisibleRoleQt::UserRole + 3Whether the layer is visible.
Esri::ArcGISRuntime::LayerListModel::LayerCanChangeVisibilityQt::UserRole + 4Whether the layer's visibility can be changed.
Esri::ArcGISRuntime::LayerListModel::LayerLoadErrorRoleQt::UserRole + 5The layer's load error type.
Esri::ArcGISRuntime::LayerListModel::LayerLoadStatusRoleQt::UserRole + 6The layer's load status.
Esri::ArcGISRuntime::LayerListModel::LayerTypeRoleQt::UserRole + 7The layer's type.
Esri::ArcGISRuntime::LayerListModel::LayerAttributionRoleQt::UserRole + 8The layer's attribution if any is available.
Esri::ArcGISRuntime::LayerListModel::LayerShowInLegendRoleQt::UserRole + 9Whether the layer will be shown in the legend.
Esri::ArcGISRuntime::LayerListModel::LayerIdRoleQt::UserRole + 10The layer's ID specified in the web map JSON.
Esri::ArcGISRuntime::LayerListModel::LayerMinScaleRoleQt::UserRole + 11The minimum scale at which the layer displays.
Esri::ArcGISRuntime::LayerListModel::LayerMaxScaleRoleQt::UserRole + 12The maximum scale at which the layer displays.
Esri::ArcGISRuntime::LayerListModel::LayerOpacityRoleQt::UserRole + 13The opacity of the layer between 0.0 and 1.0.

Member Function Documentation

LayerListModel::~LayerListModel()

Destructor.

void LayerListModel::append(Layer *layer)

Appends a layer to the layer list model.

Layer *LayerListModel::at(int index) const

Returns the Layer at the specified index.

void LayerListModel::clear()

Removes all layers from the list model.

bool LayerListModel::contains(Layer *layer) const

Returns true if the list model contains the specified layer.

[virtual] QVariant LayerListModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const

Reimplemented from QAbstractItemModel::data().

Returns the data stored under the given role for the layer referred to by the index.

  • index. The index in the model for which to return data.
  • role. The role for which to return data.

[signal] void LayerListModel::errorOccurred(Esri::ArcGISRuntime::Error error)

Signal emitted when an error occurs.

  • error - Details about the error.

Layer *LayerListModel::first() const

Returns the first layer in the list model.

int LayerListModel::indexOf(Layer *layer) const

Returns the index of the layer specified.

void LayerListModel::insert(int index, Layer *layer)

Inserts a layer at a specified index in the list model.

This method will append to the list if the index is greater than the current size of the list model.

bool LayerListModel::isEmpty() const

Returns true if the list model contains no layers.

Layer *LayerListModel::last() const

Returns the last layer in the list model.

[signal] void LayerListModel::layerAdded(int index)

Signal emitted when a layer is added to the list model.

index is the index of the added layer.

[signal] void LayerListModel::layerRemoved(int index)

Signal emitted when a layer is removed from the list model.

index is the index of the removed layer.

void LayerListModel::move(int from, int to)

Moves one layer from an index in the list model to a different index.

void LayerListModel::removeAt(int index)

Removes a layer at the specified index.

void LayerListModel::removeOne(Layer *layer)

Removes the specified layer from the list model.

int LayerListModel::size() const

Returns the number of layers contained in the list model.


Feedback on this topic?