I would like to have folder with tiles realTiles
in folder with .exe.
Of course I can add folder to qrc and everything is ok:
import QtQuick 2.10
import QtQuick.Window 2.11
import QtLocation 5.12
import QtPositioning 5.12
...
Map {
id: map
anchors.fill: parent
activeMapType: map.supportedMapTypes[0]
zoomLevel: 14
plugin: Plugin {
name: 'osm';
PluginParameter {
name: 'osm.mapping.offline.directory'
value: ':/realTiles/'
}
}
}
So I copy folder realTiles
to folder with .exe and folder one above .exe. So for example I have folder realTiles
in this 2 positions:
C:/Users/tom/Desktop/app/build-OsmOffline-Desktop_Qt_5_15_1_MinGW_64_bit-Release/release/realTiles
C:/Users/tom/Desktop/app/build-OsmOffline-Desktop_Qt_5_15_1_MinGW_64_bit-Release/realTiles
And I tried with Plugin Parameter' value:
value: 'file:///' + applicationDirPath + '/../realTiles/'
value: 'file:///realTiles/'
value: 'file:/realTiles/'
and many other. Of course I can did mistake. What is a real solution to this?
EDIT:
main.qml
import QtQuick 2.10
import QtQuick.Window 2.11
import QtLocation 5.12
import QtPositioning 5.12
Window {
id: win
objectName: "window"
visible: true
width: 512
height: 512
Map {
id: map
anchors.fill: parent
activeMapType: map.supportedMapTypes[0]
plugin: Plugin {
name: 'osm';
PluginParameter {
name: 'osm.mapping.offline.directory'
//value: ':/realTiles/'
value: 'file:///' + applicationDirPath + '/../realTiles/'
}
}
}
}
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QStandardPaths>
#include <QQmlContext>
int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath());
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
Try to give the full path
PluginParameter {
name: "osm.mapping.cache.directory"
value: "C:/Users/UserName/Desktop/OSMCache"
}
I have tried to change the cache directory it worked. So provide the full path in the value field.