Skip To Content ArcGIS for Developers Sign In Dashboard

BasemapListModel Class


The result of fetching the basemaps available for a portal. More...

Header: #include <BasemapListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<Basemap *>

Public Types

enum BasemapRoles { BasemapNameRole, BasemapUrlRole, BasemapItemAccessInformationRole, BasemapItemCreatedRole, ..., BasemapItemThumbnailUrlRole }

Public Functions

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

Reimplemented Public Functions

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


void basemapAdded(int index)
void basemapRemoved(int index)
void errorOccurred(Esri::ArcGISRuntime::Error error)

Additional Inherited Members

Detailed Description

The result of fetching the basemaps available for a portal.

The request is made by calling fetchBasemaps and if the operation is succesful, this type is returned by the portal's basemaps method.

The basemaps contained in the model are initially unloaded.

The model returns data for the following roles:

namestringThe basemap's name.BasemapNameRole
urlurlThe basemap's URL.BasemapUrlRole
accessInformationstringThe item's access information.BasemapItemAccessInformationRole
createddateThe date this item was created.BasemapItemCreatedRole
descriptionstringThe item's description.BasemapItemDescriptionRole
itemIdstringThe item's ID.BasemapItemIdRole
typePortalItemTypeThe item's type.BasemapItemTypeRole
modifieddateThe date this item was last modified.BasemapItemModifiedRole
snippetstringThe item's snippet.BasemapItemSnippetRole
tagslist<string>The item's tags.BasemapItemTagsRole
titlestringThe item's title.BasemapItemTitleRole
thumbnailUrlurlThe local file URL of the thumbnail image for this item.BasemapItemThumbnailUrlRole

Example: Accessing roles from a BasemapListModel from within a QML delegate:

Image {
    id: basemapImg
    anchors {
        horizontalCenter: parent.horizontalCenter
    height: parent.height - ( basemapLabel.height * 2 );
    source: thumbnailUrl // use the thumbnailUrl role of the model
    width: height
    fillMode: Image.PreserveAspectCrop

Text {
    id: basemapLabel
    anchors {
        bottom: parent.bottom;
        left: parent.left;
        right: parent.right
    height: 16
    z: 100
    wrapMode: Text.Wrap
    horizontalAlignment: Text.AlignHCenter
    elide: Text.ElideRight
    text: title // use the title role of the model
    font.pointSize: 8
    font.bold: index === basemapsGrid.currentIndex

See also Portal, Basemap, and Loadable.

Member Type Documentation

enum BasemapListModel::BasemapRoles

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

Esri::ArcGISRuntime::BasemapListModel::BasemapNameRoleQt::UserRole + 1The basemap's name.
Esri::ArcGISRuntime::BasemapListModel::BasemapUrlRoleQt::UserRole + 2The basemap's URL.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemAccessInformationRoleQt::UserRole + 3The item's access information.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemCreatedRoleQt::UserRole + 4The date this item was created.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemDescriptionRoleQt::UserRole + 5The item's description.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemIdRoleQt::UserRole + 6The item's ID.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTypeRoleQt::UserRole + 7The item's type.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemModifiedRoleQt::UserRole + 8The date this item was last modified.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemSnippetRoleQt::UserRole + 9The item's snippet.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTagsRoleQt::UserRole + 10The item's tags.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemTitleRoleQt::UserRole + 11The item's title.
Esri::ArcGISRuntime::BasemapListModel::BasemapItemThumbnailUrlRoleQt::UserRole + 12The local file URL of the thumbnail image for this item.

Member Function Documentation



void BasemapListModel::append(Basemap *basemap)

Appends a basemap to the basemap list model.

Basemap *BasemapListModel::at(int index) const

Returns the basemap at the specified index.

[signal] void BasemapListModel::basemapAdded(int index)

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

index is the index of the added basemap.

[signal] void BasemapListModel::basemapRemoved(int index)

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

index is the index of the removed basemap.

void BasemapListModel::clear()

Removes all basemaps from the list model.

bool BasemapListModel::contains(Basemap *basemap) const

Returns true if the list model contains the specified basemap.

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

Reimplemented from QAbstractItemModel::data().

Returns the data stored under the given role for the basemap 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 BasemapListModel::errorOccurred(Esri::ArcGISRuntime::Error error)

Signal emitted when an error occurs.

  • error - Details about the error.

Basemap *BasemapListModel::first() const

Returns the first basemap in the list model.

int BasemapListModel::indexOf(Basemap *basemap) const

Returns the index of the basemap specified.

void BasemapListModel::insert(int index, Basemap *basemap)

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

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

bool BasemapListModel::isEmpty() const

Returns true if the list model contains no basemaps.

Basemap *BasemapListModel::last() const

Returns the last basemap in the list model.

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

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

void BasemapListModel::removeAt(int index)

Removes a basemap at the specified index.

void BasemapListModel::removeOne(Basemap *basemap)

Removes the specified basemap from the list model.

int BasemapListModel::size() const

Returns the number of basemaps contained in the list model.

Feedback on this topic?