[Qgis-developer] QgsVectorJoinInfo doesn't work in PyQGIS

enzogis enzo.ciarmoli at csi.it
Tue Mar 3 11:06:43 PST 2015


Hi all, 
I think that QgsVectorJoinInfo doesn't work in PyQGIS,
I found a similar bug report http://hub.qgis.org/issues/11893 but it is in
status closed ,
thus before to open a ticket , 
I ask for help if is there something wrong here...

Tested in QGIS 2.6 - 2.8, Platform: Windows 7 , Ubuntu 14.04 LTS.

I want to join programmatically a vector layer with a table.
I tried both with postgis layers that with shp/dbf and they works fine if
the join is made manually.
But from python the results is unsuccesfully.

Code snippet:

geomLayer = iface.mapCanvas().layers()[0]
geomLayer.id()
tableLayer = iface.activeLayer()
tableLayer.id()
geomFieldName = u'comune_ist'
tableFieldName = u'codice_ist'
joinInfo = QgsVectorJoinInfo()
joinInfo.joinLayerID = tableLayer.id()
joinInfo.joinFieldName = tableFieldName
joinInfo.targetFieldName = geomFieldName
joinInfo.memoryCache = True
joinOperator=geomLayer.addJoin(joinInfo)

>From Python Console it seems ok, the result of addJoin operator is "True",
but in the qgis project there is no join...
I'm sure that the id layers are corrects.

If I open the QGS Project in a texteditor, i can see that it doesn't store
joinLayerId:
<vectorjoins>
  <join joinFieldName="codice_ist" targetFieldName="comune_ist"
memoryCache="1" joinLayerId=""/>
</vectorjoins>


What is wrong?

Any help would be greatly appreciated.
TIA




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/QgsVectorJoinInfo-doesn-t-work-in-PyQGIS-tp5191267.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list