Lucas Danzinger & Koushik Hajra
ArcGIS Runtime SDK for Qt:Building Apps
• What is Qt• ArcGIS Runtime SDK for Qt capabilities• Getting started• Fundamental development patterns• How Esri uses Qt• Where to go from here
Agenda
What is Qt?
What is the Qt Framework?
• Write once, run anywhere• Builds as native C++Portable
• Cross-platform libraries• High-level abstractions
Approach-able
• Pre-built some platforms• Source code availableOpen
- Cross platform libraries for native app development- Business logic in C++. - UI in QML (JavaScript-based)- Write once, deploy everywhere
- Linux, Windows, Mac, iOS, Android
- Platform nuances are abstracted- Abstraction APIs for common native workflows
- HTTP, local data storage, sensors, Bluetooth, etc
Qt Framework
How does it work?
Android (via JNI & NDK)
iOS(via cocoa)
macOS(via cocoa) Linux Windows
Native platformAPIs (http, file i/o,
sensors etc)
Java Objective C Objective C C++ C++
Qt Abstracted APIQNetworkManager,
QFile, etc
Qt GUI (and other) LibrariesComboBox, Button,Charts, QImage
Your App
Language
C++ Compiler clang/gcc clang clang gcc MSVC
Platform
• Windows – x86, x64• Linux – x64, arm 64 (beta)• macOS – x64• Android – armv7, armv8, x86• iOS – arm64, sim
Which platforms can I build for?
ArcGIS Runtime SDK for Qt capabilities
Offline Maps/Scenes
ArcGIS Runtime SDK for Qt
Offline Routing Offline GeocodingOffline Geometry
Symbols & Renderers(with customizations)
Geoprocessing
Search/Identify/Query/Popups
ArcGIS Platform& IdentityUtility Network
Navigation
Augmented Reality
Data Collectionand editing
Koushik Hajra
ArcGIS Runtime SDK for Qt Capabilities
Getting started
• Setup Qt: - Create account- Commercial license / open-source?- Install kits for target platforms
• Setup ArcGIS Runtime SDK for Qt- Create developer account- https://developers.arcgis.com/qt/latest/
• Install compiler / SDK dependencies- macOS/iOS: Xcode compiler- Windows: Visual Studio compiler, debugging tools- Linux: GCC compiler- Android: Android NDK and SDK
• IDE- Qt Creator
Setup
App development patterns
App Pattern API to useIdeal place to
start for
Runs on Linux, macOS & Windows
Runs on iOS & Android
QML with Qt Quick QML Web Developer Yes Yes
C++ with Qt Quick C++ C++ Developer Yes Yes
C++ with Qt Widgets C++ C++ Developer Yes No
Commonly-used pattern
https://developers.arcgis.com/qt/latest/qml/guide/qt-sdk-best-practices.htm
The QML API
• QML is a declarative language from The Qt Company- Declare components similarly to writing JSON or CSS
• Write procedural code as JavaScript functions • Create UI rapidly with Qt Quick, with animation and prebuilt controls• The QML API extends QML with new types that expose ArcGIS Runtime functionality• Used by AppStudio
The C++ API
• Flexible: Create your UI with Qt Quick (targets any platforms) or Qt Widgets (targets desktop platforms)
- Most common design pattern: QML UI, C++ business logic
• Works with Local Server (QML API doesn’t)
Need help choosing between C++ and QML APIs? See https://developers.arcgis.com/qt/latest/qml/guide/qt-sdk-best-practices.htm
Koushik Hajra
Building your first ArcGIS Runtime Qt app
Runtime fundamental patterns + Qt
Asynchronous API
• The Runtime API is a modern, asynchronous API• Tasks
- RouteTask, LocatorTask, OfflineMapTask, GeoprocessingTask, Map.save …- All follow the same pattern- All are Loadable - All have async functions to execute their tasks- TaskWatchers are returned for keep track of concurrent tasks
• Signals & Slots- Signal == “event”- Slot == “event handler”
- *Slots can be defined as standalone methods or inline lambda functions
Asynchronous API – example LocatorTask
Asynchronous API – example LocatorTask
Asynchronous API – example LocatorTask (QML)
Koushik Hajra
Asynchronous coding with Qt
Memory management
• C++ is not a managed language• Memory is not automatically handled for you
- Pros- Close to the metal- Fine tuned performance
- Fast
- Can run on memory constrained devices
- Cons- A little extra work for you
Memory management – Qt Parent/Child
• When you create a new object, you pass in a parent object. • When the parent object is deleted, so are the children• Can be any QObject – often you will see “this”• Any object you create on the heap, it is up to you to manage• Any object we return always has a parent (but you can re-set)
Memory management – Clean up when you are done
• Apps with lots of temporary graphics added and removed- You don’t want memory allocated for the lifetime of the app
• Signals passing through pointers- The parent object is set by our API- No leaks, but memory will grow each time it emits
• Use RAII – Resource Acquisition is Initialization- e.g. C++11 “smart pointers” – std::shared_ptr, std::unique_ptr- Other methods…
Memory management – QML
Koushik Hajra
C++ memory management
ListModels
• Qt’s way of doing MVC/MVVM• Mutable lists exposed as list models in Runtime API
- LayerListModel, GraphicListModel, etc
• List Models can be displayed with- ListViews- TableViews- GridViews
• Model – the data• View – what is displayed• Delegate – access the model’s “roles”
ListModels – Map Layer Documentation
ListModels – Map Layer List Example
Koushik HajraList Models
Wrap up
How is Esri using Qt?
Runtime Core (for testing)
How to get started using the SDK• Create a developer account
- https://developers.arcgis.com/sign-up
• Download Qt Framework and ArcGIS Runtime SDK for Qt- https://developers.arcgis.com/qt/latest/cpp/guide/install-and-set-up-on-windows.htm et al
• Read the guide’s fundamental topics- https://developers.arcgis.com/qt/latest/qml/guide/arcgis-runtime-sdk-for-qt.htm
• Study and modify the samples- https://github.com/Esri/arcgis-runtime-samples-qt
• Use the Forum and join the community discussion- https://geonet.esri.com/community/developers/native-app-developers/arcgis-runtime-sdk-for-qt/