Skip To Content ArcGIS for Developers Sign In Dashboard

BookmarkListModel Class


A list model storing a list of bookmarks available in a Map. More...

Header: #include <BookmarkListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<Bookmark *>

Public Types

enum BookmarkRoles { BookmarkNameRole }

Public Functions

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

Reimplemented Public Functions

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


void bookmarkAdded(int index)
void bookmarkRemoved(int index)
void errorOccurred(Esri::ArcGISRuntime::Error error)

Additional Inherited Members

Detailed Description

A list model storing a list of bookmarks available in a Map.

Modifying this model (adding, removing, moving) will update the bookmarks available in the Map.

The model returns data for the following roles:

nameQStringThe name of the bookmark.BookmarkNameRole


A common workflow would be to show the bookmark names in a QML UI, and zoom to the different bookmarks as each is selected. To do this, you could do following:

Register the BookmarkListModel type as a QML type:

qmlRegisterUncreatableType<BookmarkListModel>("Esri.Samples", 1, 0,
                                              "BookmarkListModel is an uncreatable type");

Expose the BookmarkListModel as a Q_PROPERTY:

Q_PROPERTY(QAbstractListModel* bookmarks READ bookmarks NOTIFY bookmarksChanged)

Add some Bookmarks to the list model:

// Create the bookmark from the name and viewpoint
Bookmark* bookmark = new Bookmark(name, viewpoint, this);

// Add it to the map's bookmark list
BookmarkListModel* bookmarks = dynamic_cast<BookmarkListModel*>(m_bookmarks);
if (!bookmarks)


// emit that model has changed
emit bookmarksChanged();

Use the model in a QML view:

ComboBox {
    id: bookmarkComboBox
    anchors {
        left: parent.left
        margins: 15
    property int bestWidth: implicitWidth
    width: bestWidth + indicator.width + leftPadding + rightPadding
    // Set the model to the BookmarkListModel
    model: manageBookmarksSample.bookmarks

    onModelChanged: {
        var model = bookmarkComboBox.model;
        if (model)
            var w = bestWidth;
            for (var i = 0; i < model.rowCount(); ++i) {
                metrics.text = manageBookmarksSample.bookmarkNameForIndex(i);
                w = Math.max(w, metrics.width);
            bestWidth = w;

    onCurrentTextChanged: {
        // Call C++ invokable function to to go to the bookmark

    TextMetrics {
        id: metrics
        font: bookmarkComboBox.font

Member Type Documentation

enum BookmarkListModel::BookmarkRoles

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

Esri::ArcGISRuntime::BookmarkListModel::BookmarkNameRoleQt::UserRole + 1The name of the bookmark.

Member Function Documentation



void BookmarkListModel::append(Bookmark *bookmark)

Appends a bookmark to the bookmark list model.

Bookmark *BookmarkListModel::at(int index) const

Returns the bookmark at the specified index.

[signal] void BookmarkListModel::bookmarkAdded(int index)

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

index is the index of the added bookmark.

[signal] void BookmarkListModel::bookmarkRemoved(int index)

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

index is the index of the removed bookmark.

void BookmarkListModel::clear()

Removes all bookmarks from the list model.

bool BookmarkListModel::contains(Bookmark *bookmark) const

Returns true if the list model contains the specified bookmark.

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

Reimplemented from QAbstractItemModel::data().

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

Signal emitted when an error occurs.

  • error - Details about the error.

Bookmark *BookmarkListModel::first() const

Returns the first bookmark in the list model.

int BookmarkListModel::indexOf(Bookmark *bookmark) const

Returns the index of the bookmark specified.

void BookmarkListModel::insert(int index, Bookmark *bookmark)

Inserts a bookmark 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 BookmarkListModel::isEmpty() const

Returns true if the list model contains no bookmarks.

Bookmark *BookmarkListModel::last() const

Returns the last bookmark in the list model.

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

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

void BookmarkListModel::removeAt(int index)

Removes a bookmark at the specified index.

void BookmarkListModel::removeOne(Bookmark *bookmark)

Removes the specified bookmark from the list model.

int BookmarkListModel::size() const

Returns the number of bookmarks contained in the list model.

Feedback on this topic?