QML samples

Download


Interactive samples app

QML samples are provided in an interactive samples app that gets installed when you install ArcGIS Runtime SDK for Qt. The app illustrates the range of mapping and GIS capabilities you can add to your own QML-based apps. Each live sample includes a description, and QML code you can copy into your own project.

The app is cross-platform, running on all platforms supported by the QML API in the ArcGIS Runtime SDK for Qt, including mobile phones. However, it is designed and tested for tablets, desktops, and laptops.

Shortcuts on the desktop and in the installation directory are created during installation.

The My Samples tab

The My Samples tab of app contains links to samples stored locally on your device in the home folder under My Qml Samples. You can copy your own samples into this folder using a file browser.

The following are the slightly varying folder paths on different operating systems:

  • Windows: %USERPROFILE%\ArcGIS\Runtime\My Qml Samples
  • Mac: ~/ArcGIS/Runtime/My Qml Samples
  • Linux: $Home/ArcGIS/Runtime/My Qml Samples
  • Android: /sdcard/ArcGIS/Runtime/My Qml Samples

Each sample must be contained within its own subfolder under the folder named My QML Samples. Each sample also requires certain files, listed in the next section.

Required files

The following files must accompany your QML file in the sample folder.

  • sample.html contains a thumbnail and short description of the sample. This content displays on the description tab of the app.
  • sample.json contains the path names of the source QML file, the thumbnail, and the description. It includes path references to data that is used by the sample. The data reference includes both the ArcGIS Online item ID where the data is to be sourced from and the local data path where it will be saved. The local path is relative to the location of the QML Sample App to ensure that it will work on all platforms.
  • sample.png contains the thumbnail image for the sample used in the table of contents list and the description tab.
  • sample.qml contains the QML code for the sample.

The .json file must be named sample.json but there is no forced naming convention for the rest of the files. It is easiest to use the same name for each of these files (the examples below use "sample") but if you choose different names, be sure to reference these names correctly inside the other files.

Valid JSON

If you're having trouble viewing a sample you added to the app, a common problem is invalid JSON in the sample.json file. Consider using one of the numerous online tools for checking and correcting JSON notation.

The key JSON syntax elements to remember are the following:

  • All strings must be enclosed in double quotation marks.
  • All [] (square brackets) and {} (braces) must be closed pairs.
  • A comma is required at the end of each variable line.

The toolkit

Sample code for utilities and controls such as a user-credential dialog box, a map toolbar, and a search box are provided in the open source toolkit for ArcGIS Runtime SDK for Qt, available in the arcgis-runtime-toolkit-qt GitHub repo.