« Previous - Version 9/36 (diff) - Next » - Current version
Alexander Bruy, 01/29/2012 05:23 am


API changes for version 2.0

This is a list of changes for 2.0 which are breaking the API compatibility. It also serves as a basic guide on how to port plugins from 1.x to 2.0

QgsComposerView

Removed methods:
  • addComposerLabel
  • addComposerMap
  • addComposerScaleBar
  • addComposerLegend
  • addComposerPicture
  • addComposerShape
  • addComposerTable
  • pushAddRemoveCommand
  • sendItemAddedSignal
Removed signals:
  • composerLabelAdded
  • composerMapAdded
  • composerScaleBarAdded
  • composerLegendAdded
  • composerPictureAdded

To port 1.x plugins, use the corresponding methods and signals of QgsComposition

PostrgeSQL data provider

Look at ce4fc1daa5

Best practises for Plugin developers

During a transition time, a plugin sould work with both the old and new API.
This can be achieved with exception handling in an import clause e.g.:

try:
    from qgis.core import newFunctionName as newFunctionName
except:
    from qgis.core import oldFunctionName as newFunctionName

Following the duck typing scheme of dynamic langagues, this could also be done before calling the function:

if hasattr(composerView, "addComposerShape"):
    composerView.addComposerShape(item)
else:
    composition.addComposerShape(item)