Skip to content

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

GEM QML guide - setting your api key

In Qt, go to the File menu and select Open File or Project…

GEM QML guide - setting your api key

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.

GEM QML guide - setting your api key

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

GEM QML guide - setting your api key

The project is now open. Click on the project name near the upper left corner of the window to select it.

GEM QML guide - setting your api key

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.

GEM QML guide - setting your api key

Replace YOUR_TOKEN with your actual API key token.

GEM QML guide - setting your api key

Click the green triangle Play button near the lower left corner of the window to compile and run the project.