[Qgis-developer] Making QgsProject available to python plugins

Sandro Santilli strk at keybit.net
Sat Sep 29 08:03:21 PDT 2012


On Sat, Sep 29, 2012 at 02:45:10PM +0200, Sandro Santilli wrote:
> On Sat, Sep 29, 2012 at 02:36:37PM +0200, Sandro Santilli wrote:
> > On Sat, Sep 29, 2012 at 03:32:58PM +0300, Alexander Bruy wrote:
> > > AFAIK, QgsProject already available from Python. Just use
> > > QgsProject.instance() to access it. Maybe you mean that
> > > some methods currently not exposed in Python API?
> > 
> > NameError: global name 'QgsProject' is not defined
> 
> Fixed by:
> 
>  from qgis.core import *
> 
> Now what I'm after is adding each of the layers defined in one project
> into another one. Would "createEmbeddedLayer" do that for me ?
> I do know the names of each layer in the source project.

I've spent hours on trying to expose createEmbeddedLayer but
had no luck and now giving up (no more fun for me).

When I uncommented the createEmbeddedLayer method in the
qgsproject.sip file, the sip compiler complained with:

 unsupported function argument type - provide %MethodCode and a valid C++ signature

Since I didn't so many %MethodCode used I tried (unsuccessfully)
to provide a %MappedType in conversions.hpp instead.

If anyone has further pointers I might get back on the issue.

--strk; 


More information about the Qgis-developer mailing list