Qt is one of the most popular cross-platform application frameworks. It's easy to integrate CartoType into a Qt application. Qt-compatible CartoType libraries are shipped with the Windows and Linux SDKs.
CartoType for Qt is available for Windows, Linux and Mac OS. For Windows and Linux, Qt-compatible libraries are shipped with the SDKs; for Mac OS, libraries are available on request.
To evaluate CartoType using Qt on Windows (64-bit), download the Windows SDK from the SDKs page,and link your Qt app to these libraries:
- 64-bit release build: CartoType\bin\15.0\x64\ReleaseDLL\cartotype.lib and CartoType\bin\15.0\x64\ReleaseDLL\CartoTypeQtMapRenderer.lib
- 64-bit debug build: CartoType\bin\15.0\x64\DebugDLL\cartotype.lib and CartoType\bin\15.0\x64\DebugDLL\CartoTypeQtMapRenderer.lib
The suffix DLL indicates that the libraries link to the DLL version of the C++ runtime library, not the static version.
How to build and run the sample Maps App using Windows:
1. Create a directory for the SDK and sources. It is called \cartotype-eval in these instructions.
2. Obtain the Windows SDK as the file cartotype_windows_sdk_evaluation_N.N.NNN.zip from http://www.cartotype.com/developers/evaluation-sdks, where N.N and NNN are the version number and build number.
3. Unzip the SDK (in Windows Explorer use a right mouse click 'Extract All...') into the directory \cartotype-eval.
4. Get the public CartoType sources from the public repository and put them into the directory \cartotype-eval.
5. Open the Maps app project file \cartotype-eval\CartoType-Public\src\apps\Maps\Maps.pro in Qt Creator.
6. Configure the project to use Desktop Qt 5.10.1 MSVC2017 64bit, and choose either the Debug or Release build.
7. Edit maps.pro to link the libraries from the SDK by changing the
win32: section near the end of the file to this (changing N.N.NNN to the version and build of your evaluation SDK):
CONFIG(debug, debug|release): LIBS += -L/cartotype-eval/cartotype_windows_sdk_evaluation_N.N.NNN/CartoType/bin/15.0/x64/DebugDLL/ -lcartotype -lCartoTypeQtMapRenderer
else:CONFIG(release, debug|release): LIBS += -L/cartotype-eval/cartotype_windows_sdk_evaluation_N.N.NNN/CartoType/bin/15.0/x64/ReleaseDLL/ -lcartotype -lCartoTypeQtMapRenderer
8. Run qmake (Build->Run qmake).
9. Build the project (Build->Build project "Maps").
10. Run the program using the Run command (Build->Run).
To evaluate CartoType using Qt on Linux (64-bit AMD-64), download the Linux SDK from the SDKs page,and link your Qt app to these libraries:
- 64-bit release build: cartotype-linux-sdk/bin/libcartotype.a and cartotype-linux-sdk/bin/libCartoTypeQtMapRenderer.a
You may need to install OpenGL libraries to enable graphics acceleration. Mesa is one of the most popular implementations.
You use the C++ API to work with CartoType in Qt.
Choosing a rendering system
Hardware acceleration is smoothest and fastest way to render maps, so that's what you should choose if possible, but you can also use software rendering if you like. The Maps App allows the user to turn hardware accelerated rendering on and off. For guidance on how to do this please see the Maps App source code; a good place to start reading the code is the function MapForm::SetGraphicsAcceleration in src/apps/Maps/mapform.cpp.
If you use software rendering you'll need a function to convert CartoType map bitmaps to QImage objects so that you can draw them in your application window. There's a function called CopyBitmapToImage to do that in the Maps App, in src/apps/Maps/util.cpp.