在我的跨平台应用程序中,我使用定制的qt geoservices插件,它在桌面应用程序中工作正常。但是,只要我尝试在Android应用中使用它,QML PLugin对象无法加载我的插件,但仍然可以加载qt内置地理服务插件,如此处或 osm 即可。但是,我可以通过QPluginLoader手动加载我的插件:
QPluginLoader loader("libplugins_geoservices_libqtgeoservices_empty.so");
if (loader.load()) {
qDebug() << loader.metaData();
loader.unload();
}
loader.setFileName("libplugins_geoservices_libqtgeoservices_osm.so");
if (loader.load()) {
qDebug() << loader.metaData();
loader.unload();
}
带输出:
QJsonObject({"IID":"org.qt-project.qt.geoservice.serviceproviderfactory/5.0","MetaData":{"Experimental":false,"Features":["OfflineMappingFeature"],"Keys":["empty"],"Provider":"empty","Version":100},"className":"EmptyGeoServiceProviderFactory","debug":false,"version":328961})
QJsonObject({"IID":"org.qt-project.qt.geoservice.serviceproviderfactory/5.0","MetaData":{"Experimental":false,"Features":["OnlineMappingFeature","OnlineGeocodingFeature","ReverseGeocodingFeature","OnlineRoutingFeature","OnlinePlacesFeature"],"Keys":["osm"],"Provider":"osm","Version":100},"className":"QGeoServiceProviderFactoryOsm","debug":false,"version":328961})
QML代码:
Plugin {
id: mapPlugin
// name: "empty" // doesn't work
name: "osm" // works fine
Component.onCompleted: console.log(availableServiceProviders) // outputs: "here,osm,mapbox"
}
我在桌面和Android版本中使用Qt 5.5。