我想在我的Qt C ++应用程序中使用python脚本,并且被困在将QgsVectorLayer类型的指针传递给python方法,并在处理完后从python脚本获取更新的图层引用。例如,python脚本是
import processing
layer = canvas.layer(0)
cellsize = 1000
input = processing.getobject(layer.name())
centerx = (input.extent().xMinimum() + input.extent().xMaximum()) / 2
centery = (input.extent().yMinimum() + input.extent().yMaximum()) / 2
width = (input.extent().xMaximum() - input.extent().xMinimum())
height = (input.extent().yMaximum() - input.extent().yMinimum())
grid="/yourpath/grid.shp"
processing.runandload("qgis:creategrid", cellsize, cellsize, width, height, centerx, centery, 1, input.crs().authid(), grid)
此处应从C ++传递该层,并应通过引用返回创建的内存层