How to remove deprecated API usage from your C++ Qt apps

2159
0
09-02-2022 12:41 PM
Labels (1)
LucasDanzinger
Esri Frequent Contributor
2 0 2,159

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

To simplify identifying deprecated APIs in C++, we’ve created a macro,  QRT_DEPRECATED, that will raise compiler warnings for any deprecated usage in your app. The warnings will show up in Qt Creator like this:

LucasDanzinger_0-1662147557457.png

Qt Creator will also call out any usage in the code editor, making it very easy to identify where to make the changes.

LucasDanzinger_1-1662147557460.png

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

LucasDanzinger_2-1662147557465.png

The QRT_DEPRECATED macro is enabled by default, so you will see these warnings automatically. 

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.