I have an issue with a plugin for QGIS 2.8 I'm developing when using it on a Windows 64bit machine (as opposed to 32bit).

I am trying to update values in a particular field in my plugin, and the values are not updated when running the plugin on the 64bit machine.

I notice that the Generic Type and Identified Type for this field are different when opening the project on each type of machine. The field has a Generic Type "int" and Identified type "Integer" on the 32 bit machine, while on the 64 bit machine the same field has a Generic Type "QString" and an Identified type "Integer64". The code below does work when updating a field of Generic Type "double" (Identified Type "real" on the 64 bit machine) and Generic Type QString (with identified Type "string"), the values are updated. However, I am wondering if I can also get it working for the former case.

UPDATE Something strange I am noticing on the 64bit computer, is that I am unable to keep a field in the Generic Type "double" nor Generic Type "int". Once this field is created in int or real--when the project is saved, closed, and reopened, the field Generic Type becomes QString and Integer64 once again (the data type that I am unable to update via my plugin).

UPDATE #2 Further testing has shown that the values are updated and the field type stays "int" when editing on a 64bit machine using QGIS 2.8.3. The issues I had were with another 64bit machine running QGIS 2.8.7. Could this be an version issue instead of a system issue?

Below is the code I used to update the values:

    self.Nature_idx = self.resLayer.fieldNameIndex('MATERIAU')
    #This field below is the problematic one, with inconsistent data types on 32 vs 64 bit computers
    self.Diam_idx = self.resLayer.fieldNameIndex('DIAMETRE')
    self.resMain_idx = self.resLayer.fieldNameIndex('MAINT')
    self.fuitesNature_idx = self.fuitesLayer.fieldNameIndex('NaturCanal')
    #This field below is the one carrying the value I would like to carry over and update in the previous field. It has a generic type "Double" and Identified Type "real"
    self.fuitesDiam_idx = self.fuitesLayer.fieldNameIndex('DiamCanal')
    self.fuitesOrigin_idx = self.fuitesLayer.fieldNameIndex('OriginInfo')

    self.fuitesSelectList = []
    self.fuitesNatureList = []
    self.fuitesDiamList = []
    self.fuitesOriginList = []

    for feature in self.fuitesLayer.getFeatures():
        if feature.id() == fid:

    caps = self.resLayer.dataProvider().capabilities()
    fid = self.selectList[0]
    newNature = self.fuitesNatureList[0]
    newDiam = self.fuitesDiamList[0]

    #FYI: I get integers here
    #QMessageBox.information(None, 'DEBUG', newDiam)

    self.resMaint_idx = self.resLayer.fieldNameIndex('MAINT')
    if caps & QgsVectorDataProvider.ChangeAttributeValues:
        attrs = {self.Nature_idx : newNature, self.Diam_idx : newDiam, self.resMaint_idx : 'fuite_reparee'}
        self.resLayer.dataProvider().changeAttributeValues({fid : attrs})
  • Check the gdal versions - this behaviour has changed between gdal 1 and 2 – ndawson Apr 26 '16 at 23:43

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.