[Qgis-developer] plug ins- how to start

Richard Duivenvoorde rdmailings at duif.net
Thu Oct 16 03:38:10 EDT 2008


Hi Elizabeth,

as Paolo mentioned, the standard Postgis layer (Layer / Add a Postgis 
layer) makes it possible to connect to postgis, view the geometries AND 
view/edit/save the attribute data.
If that's what you want, you're done :-)

But if you just want to write some code /plugin for qgis, go ahead.

You can either write your plugin in cpp (which is/was the normal way 
pre-0.8 or so). The Copyrightlabel, GPS Tools etc are written in cpp. 
But you will need a full cpp build environment (which I think is a 
little easier to make in ubuntu (???)).

In my opinion, the easiest way to write a plugin is in python. Search 
the wiki for python plugin:
http://wiki.qgis.org/qgiswiki/PluginRepositories?action=fullsearch&context=180&value=python+plugin&fullsearch=Text
I think http://wiki.qgis.org/qgiswiki/DevelopingPluginsWithPython is a 
good page to start :-)

In this way you do NOT need to rebuild qgis at all. You can just start 
hacking into one of the existing easier plugins (sources) into (on 
windows where you apparently are developing in)
"C:\Documents and Settings\[YOURNAME]\.qgis\python\plugins"

So install qgis and python, and install for example the "Raster File 
Info" plugin via the plugin-installer OR by just extracting the zip from 
: http://spatialserver.net:3001/python_plugins/list?page=2
into your C:\Documents and Settings\[YOURNAME]\.qgis\python\plugins 
directory.
As you can see, you can use existing plugins to peep into the source for 
ideas etc. There are already some postgis-related plugins available 
(from: http://spatialserver.net:3001/python_plugins/list):
- PostGPS: A set of dialogs for converting a point layer into a .gpx 
file and to take a any point layer and insert it into a PostGIS table
- NewLayer  	Example of how to create a new minimal PostgreSQL layer 
with predefined field types (not very useful but demonstrates the concept).
- pypostgis  	Plugin to run queries from inside qgis and load them into 
the canvas. Uses OGR as connection library.

One remark: in this time (just before the 1.0 release of qgis) there are 
some api-changes, so beware of that).

Another remark: there is also a difference in making a plugin with nice 
dialogs, of plugins with only  msg-box-like alerts.

Developing plugins with dialogs you will need to set up qt and pyqt to 
build those dialogs. But I would say: start with alerts first ...
(see my first steps in plugins: http://www.duif.net/qgis/ with some 
links in it)

Regards and have fun,

Richard Duivenvoorde






Chang, Elizabeth wrote:
> Hi,
> 
>  
> 
> I recently started looking into building a QGIS plugin in that would 
> connect to PostGIS and be able to edit database entries.
> 
>  
> 
> How do I go about starting this? I want to make an external plug-in. I 
> started creating the development environment following 
> http://www.webalice.it/marco.pasetti/qgis+grass/BuildFromSource.html and 
> ran into problems. I’ll have to try it again and get the exact error 
> message but in short, when I got to installing GRASS, it said that it 
> couldn’t find Lex. I had installed Flex by downloading the prebuilt 
> binary package and somehow GRASS installation couldn’t find it. When I 
> went to reinstall Flex by building it myself, I think it said that it 
> couldn’t find Bison which I had also installed using prebuilt binaries. 
> How do I get it to find Flex and Bison? BTW, I’m building this on 
> Windows using msys.
> 
>  
> 
> In the meantime, I ran into 
> http://wiki.qgis.org/qgiswiki/DevelopingPlugins?highlight=%28plug%29 
> which is outdated but seems to say that I don’t need the entire 
> development environment.
> 
>  
> 
> Could someone give me any pointers on this endeavor? I’m a newbie. I 
> know some programming in Java but not on C++ or Python and planning to 
> learn what I have to learn to do this.
> 
>  
> 
> Thanks,
> 
> Elizabeth
> 
>  
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list