Setting your API Key¶
In this guide you will learn how to set your API key token as a C++ property accessible from QML.
First, get an API key token, see the Getting Started guide.Qt should be installed to continue.
Maps SDK for Qt should be installed to continue, see the Setup Maps SDK for Qt guide.
How to set your API key token in C++ code for QML¶
In Qt, go to the File menu and select Open File or Project…
then browse to the ProjectName folder and open ProjectName.pro, where ProjectName is the name of the existing project, such as an example, you want to open.
The first time you open a project, the Configure Project panel appears. Select at least the Sphere KDAB Desktop kit and the Android kit, then click Configure Project
The project is now open. Click on the project name near the upper left corner of the window to select it.
Type an asterisk, that is, * to open the entire tree and show all files in the project. Double click on main.cpp to open this file.
Replace YOUR_TOKEN with your actual API key token.
Click the green triangle Play button near the lower left corner of the window to compile and run the project.