Skip To Content ArcGIS for Developers Sign In Dashboard

GraphicListModel Class

(Esri::ArcGISRuntime::GraphicListModel)

A container class storing a list of graphics available in a GraphicsOverlay. More...

Header: #include <GraphicListModel>
Since: Esri::ArcGISRuntime 100.0
Inherits: QAbstractListModel and Iterable<Graphic *>

Public Types

enum GraphicRoles { GraphicSelectedRole, GraphicVisibleRole, GraphicZIndexRole, GraphicAttributesRole }

Public Functions

~GraphicListModel()
void append(Graphic *graphic)
void append(const QList<Graphic *> &graphics)
Graphic *at(int index) const
void clear()
bool contains(Graphic *graphic) const
Graphic *first() const
int indexOf(Graphic *graphic) const
void insert(int index, Graphic *graphic)
bool isEmpty() const
Graphic *last() const
void move(int from, int to)
void removeAt(int index)
void removeOne(Graphic *graphic)
int size() const

Reimplemented Public Functions

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

Signals

void graphicAdded(int index)
void graphicRemoved(int index)

Additional Inherited Members

Detailed Description

A container class storing a list of graphics available in a GraphicsOverlay.

Modifying this collection (adding, removing, moving) will update the graphics available in a GraphicsOverlay. Moving a graphic's position in the list model does not affect drawing order. To change drawing order, use the Graphic::zIndex property on each Graphic.

The model returns data for the following roles:

RoleTypeDescriptionGraphicRoles
selectedboolWhether the graphic is selected.GraphicSelectedRole
graphicVisibleboolWhether the graphic is visible.GraphicVisibleRole
zIndexintThe z index of the graphic.GraphicZIndexRole
attributesQVariantMapThe attributes of the graphic.GraphicAttributesRole

See also GraphicsOverlay and Graphic.

Member Type Documentation

enum GraphicListModel::GraphicRoles

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

ConstantValueDescription
Esri::ArcGISRuntime::GraphicListModel::GraphicSelectedRoleQt::UserRole + 1Whether the graphic is selected.
Esri::ArcGISRuntime::GraphicListModel::GraphicVisibleRoleQt::UserRole + 2Whether the graphic is visible.
Esri::ArcGISRuntime::GraphicListModel::GraphicZIndexRoleQt::UserRole + 3The z index of the graphic.
Esri::ArcGISRuntime::GraphicListModel::GraphicAttributesRoleQt::UserRole + 4The attributes of the graphic.

Member Function Documentation

GraphicListModel::~GraphicListModel()

Destructor.

void GraphicListModel::append(Graphic *graphic)

Appends the graphic to the graphic list model.

void GraphicListModel::append(const QList<Graphic *> &graphics)

Appends graphics to the graphic list model.

Graphic *GraphicListModel::at(int index) const

Returns the graphic at the specified index.

void GraphicListModel::clear()

Removes all graphics from the list model.

bool GraphicListModel::contains(Graphic *graphic) const

Returns true if the provided graphic is in the list model.

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

Reimplemented from QAbstractItemModel::data().

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

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

Graphic *GraphicListModel::first() const

Returns the first graphic in the list model.

[signal] void GraphicListModel::graphicAdded(int index)

Signal emitted when a graphic is added to the list.

index is the index of the added graphic.

[signal] void GraphicListModel::graphicRemoved(int index)

Signal emitted when a graphic is removed from the list.

index is the index of the removed graphic.

int GraphicListModel::indexOf(Graphic *graphic) const

Returns the index of the provided graphic in the list model.

void GraphicListModel::insert(int index, Graphic *graphic)

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

bool GraphicListModel::isEmpty() const

Returns true if this list model is empty.

Graphic *GraphicListModel::last() const

Returns the last graphic in the list model.

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

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

Moving a graphic's position in the list model does not affect drawing order. To change drawing order, use the Graphic::zIndex property on each Graphic.

void GraphicListModel::removeAt(int index)

Removes a graphic at the specified index in the list model.

void GraphicListModel::removeOne(Graphic *graphic)

Removes the specified graphic from the list model.

int GraphicListModel::size() const

Returns the number of graphics in the model.


Feedback on this topic?