Select to view content in your preferred language

How to remove deprecated API usage from your Qt QML apps

1339
0
09-02-2022 12:45 PM
Labels (1)
LucasDanzinger
Esri Frequent Contributor
2 0 1,339

As discussed in a previous blog, a critical step to take in preparing your apps for version 200 is to replace deprecated APIs with current APIs and contemporary code. This blog describes how to do this in QML.

Because QML is an interpreted language, it does not currently have a compiler, linter, or IDE tools to help you easily identify deprecated API usage. As such, we’ve introduced a property on ArcGISRuntimeEnvironment named logDeprecatedWarnings. This property logs to the console whenever a deprecated class, property, method, or signal is used in your app. The log content contains the API name that is deprecated, as well as the file and line number in some circumstances.

LucasDanzinger_0-1662147767999.png

After identifying deprecated API usage, consult the API reference doc to find a suitable replacement and make appropriate changes to your code.

LucasDanzinger_1-1662147768004.png

Please note  that these warnings are run-time warnings, not compile-time warnings. This means the warnings will be logged throughout the lifetime of running your apps. Thus, it is important to fully test your app to ensure all code paths are run. Some common potential pitfalls include:

  •  QML files or Components that are loaded with a QML Loader, StackView, or other similar pattern. The QML engine will not parse these files or components until they are loaded, so it is essential that your app testing loads all QML files and code.

LucasDanzinger_2-1662147768009.png

  • JavaScript code is not parsed by the QML engine when the file is loaded, but rather when the JavaScript code is run. For example, in this case the warning will be logged when the button is clicked.

LucasDanzinger_3-1662147768013.png

This property is enabled by default. It can be disabled by setting the property to false.

 

About the Author
I'm a Geographer working in Product Development at Esri, focusing my time on the ArcGIS Runtime SDKs. I'm an Esri Certified ArcGIS Desktop Professional (10 years experience working with ArcGIS) with a wide range of technical skills including native application development, spatial databases, desktop/web GIS, and scripting. My Master's degree is in GIS with a focus in Natural Resource Management. Currently, I'm most interested in building cross-platform and lightweight apps using our ArcGIS Runtime SDK for Qt.