I am developing a cross-platform mobile application which must display a geographical map. then we're using Qt framework (Qt 5.9), and the main part of the implementation is in C++.
Qt has ready-to-use Map objects available in QML. Then, the best way I found to integrate the map view is to load QML code into a QQuickWidget.
The following piece of code works fine on MacOS Desktop but I am still getting a blank view when deploying on iOS.
map.qml
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtLocation 5.9
import QtPositioning 5.5
Map {
id: map
plugin: Plugin {
name: "mapboxgl"
PluginParameter { name: "mapboxgl.access_token"; value: "***" }
}
center: QtPositioning.coordinate(60.170448, 24.942046) // Helsinki
zoomLevel: 8
width: 500 // no effects since it will be resized
height: 500 // no effects since it will be resized
gesture.enabled: true
Component.onCompleted: {
console.log("Dimensions: ", width, height) // print 500 500 whether or not the map is displayed
}
}
viewport.cpp
Viewport::Viewport(QWidget *parent) : QWidget(parent),
_engine(new QQmlEngine(this)),
_mapview(new QQuickWidget(_engine,this)),
_toolbar(new Toolbar(this)) // subclass of QWidget
{
_mapview->setSource(QUrl("qrc:/map.qml"));
_mapview->setResizeMode(QQuickWidget::SizeRootObjectToView);
}
Note :
map.qml
is properly declared at the root of a qt resource file, so that mobile device can access it. I know mapboxgl plugin is very new on Qt 5.9 No matter what plugin I use for the map (osm, mapbox, mapboxgl) I'm always getting a blank view on iOS, with no error message.- When running a simple sample project, the warning message for mapboxgl plugin is something like
ssl handshake failed
. Even though Qt says the mapboxgl QML plugin, for instance, supports iOS. - The
Viewport
class inherits from QWidget and is not associated to any ui file, both of the_mapview
and the_toolbar
geometries are managed by hand. For the moment there is no overlapping widgets and all of them are fully opaque. Nevertheless I tried to set/unset several OpenGL attributes (Qt::AA_UseOpenGLES
,Qt::AA_ShareOpenGLContexts
etc...) but still don't do the thing ... - Last note : replacing the map of the above code, with a simple red Rectangle with a Text on it works well.
My question what am I doing wrong ? Did I miss something in the documentation ? Nothing says iOS cannot support these map qml objects.