Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Feature layer definition expression

Sample Viewer View Sample on GitHub

Limit the features displayed on a map with a definition expression.

Use case

Set a definition expression to filter out the features to be displayed. You might filter a dataset of tree quality selecting for only those trees which require maintenance or are damaged.

How to use the sample

Press the 'Apply Expression' button to limit the features requested from the feature layer to those specified by the SQL query definition expression. Click the 'Reset Expression' button to remove the definition expression on the feature layer, which returns all the records.

How it works

  1. Create a service feature table from a URL.
  2. Create a feature layer from the service feature table.
  3. Set the limit of the features on your feature layer using the definitionExpression.

Relevant API

  • DefinitionExpression
  • FeatureLayer
  • ServiceFeatureTable

About the data

This map displays point features related to crime incidents that have been reported by city residents.


definition expression, filter, limit data, query, restrict data, SQL, where clause

Sample Code

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.9

//! [Rectangle-mapview-map-viewpoint]
Rectangle {
    width: 800
    height: 600


    // Map view UI presentation at top
    MapView {
        id: mv

        anchors.fill: parent
        wrapAroundMode: Enums.WrapAroundModeDisabled

        Map {
            BasemapTopographic {}
            initialViewpoint: viewPoint

            FeatureLayer {
                id: featureLayer

                ServiceFeatureTable {
                    id: featureTable
                    url: ""

        ViewpointCenter {
            id: viewPoint
            center: Point {
                x: -13630484
                y: 4545415
                spatialReference: SpatialReference {
                    wkid: 102100
            targetScale: 300000
    //! [Rectangle-mapview-map-viewpoint]

    Row {
        id: expressionRow
        anchors {
            bottom: parent.bottom
            left: parent.left
            right: parent.right
            margins: 5
            bottomMargin: 25
        spacing: 5

        // button to apply a definition expression
        Button {
            text: "Apply Expression"
            enabled: featureTable.loadStatus === Enums.LoadStatusLoaded
            onClicked: {
                featureLayer.definitionExpression = "req_Type = \'Tree Maintenance or Damage\'"

        // button to reset the definition expression
        Button {
            text: "Reset"
            enabled: featureTable.loadStatus === Enums.LoadStatusLoaded
            onClicked: {
                featureLayer.definitionExpression = "";