I'm developing a plugin in QGIS 2.8.2 using Pyqt 4. Well the idea is using the processing 'qgis:extractbylocation' from the QGIS algorithm provider to capture the studied area

# Récupérer tous les iris qui s'intersectent avec la zone d'étude
res = processing.runalg('qgis:extractbylocation', irisLayer, layerZone, u'intersects', 0, None)

# Créer une couche vector issue de l'extraction des IRIS dans la zone
ObjectifVilleExtract.irisLayer = QgsVectorLayer(res['OUTPUT'], "IRIS dans la zone d'etude", "ogr")

# Définir un ecodage Windows compatible avec le français

# Modifier l'encoage

# Vérifier que le couche est valide sinon afficher que la couche est erronée
if not ObjectifVilleExtract.irisLayer.isValid():
    print "Layer failed to load!"

Then showing the results on a listview:

ObjectifVilleExtract.features = ObjectifVilleExtract.irisLayer.getFeatures()
ObjectifVilleExtract.model = QStandardItemModel(ObjectifVilleExtract.features)
for feature in ObjectifVilleExtract.features:
    item = QStandardItem(feature['nom_iris'])

Now I want to capture checked item on the listview, to apply on its the following processes :

iter = ObjectifVilleExtract.features.getFeatures()
for feature in iter :
    q1 = "SELECT nom_com FROM france_full_data.contours_iris WHERE code_iris='" + feature['code_iris'] + "' "

I tried to use the following code :

for feature in ObjectifVilleExtract.features:
    while ObjectifVilleExtract.model.item(feature['nom_iris']) :
        if ObjectifVilleExtract.model.item(feature['nom_iris']).ischecked():
            ObjectifVilleExtract.iter = ObjectifVilleExtract.irisLayer.getFeatures()
            for feature in ObjectifVilleExtract.iter :
                q1 = "SELECT nom_com FROM france_full_data.contours_iris WHERE code_iris='" + feature['code_iris'] + "' "

the result is empty !

  • 2
    And here comes the obvious question: Why are you developing for an outdated version which isn't supported anymore? – Erik Jul 8 at 10:42
  • 1
    i'm doing an intership in an agency where they're using this version . So i'm obliged to develop for the 2.8.2 version of qgis even if it's oudated – zak Jul 8 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.