Hello,
I'm trying to change the path property of a ShapefileFeatureTable by a fileUrl taked from a FileDialog.
I'm trying with this code:
Mapview{
id:mapView
Map{
FeatureLayer{
ShapefileFeatureTable{
id:shpfile
}
}
}
}
FileDialog {
id: fileDialog
title: "Ouvrir un fichier shapefile"
folder: shortcuts.home
nameFilters: [ "Shapefile (*.shp)"]
onAccepted: { fileDialog.close shpfile.path=fileUrl shpfile.retryLoad() } onRejected: { fileDialog.close()
}
}
The Probem is: on the first add it's work, but on the second add it look like that the path does not change it remain the first Shapfile path.
Thank you for your Help
Mustapha,
After reading the documentation from ArcGIS Runtime SDK for Qt, on ShapefileFeatureLayer, I think you need to call close() function before resetting the path again to forcefully remove all internal references to it.
ShapefileFeatureTable QML Type | ArcGIS for Developers
Thank you,
Erwin
on the first add it's work, but on the second add it look like that the path does not change it remain the first Shapfile path.
If it works the first time, this is expected. The ShapefileFeatureTable is a Loadable object. Once it successfully reaches the loaded state, you cannot change the path and reload it. Details on this can be found in the guide topic for
Instead of trying to re-purpose the object and change the path, you'll need to instantiate a new shapefile feature table and feature layer and add it to the map.
For example (have not executed this, so there may be slight syntax issues...):
onAccepted: {
var ft = ArcGISRuntimeEnvironment.createObject("ShapefileFeatureTable", {path: fileUrl});
var fl = ArcGISRuntimeEnvironment.createObject("FeatureLayer", {featureTable: ft});
map.operationalLayers.append(fl);
}