[Qgis-developer] Qgis standalone apps

Massimo Di Stefano massimodisasha at yahoo.it
Thu Sep 9 18:10:25 EDT 2010


Hi All,

i'm tring to start some coding on the qgis api
i'm on osx 10.6.4 running qgis 1.6

following the example from : 


http://mapserver.sk/~wonder/qgis/html/canvas.html#using-map-tools-with-canvas

it works fine if i call it from a qgis-python shell

but i tried to make small changes to have it running as a standalone application,

i eliminated the "layer" from the init line :  

QMainWindow.__init__(self)

used a custom extent :

self.canvas.setExtent('15.1845401903089403,40.6214856769878665 : 15.2339879807105998,40.6477493100907381')

and commented out the line :

#self.canvas.setLayerSet( [ QgsMapCanvasLayer(layer) ] )

then from a standard python shell, i tried :

>>> import mywnd
>>> dir(mywnd)
['MyWnd', 'QAction', 'QMainWindow', 'QString', 'QgisInterface', 'QgsAnnotationItem', 'QgsColorButton', 'QgsColorButtonV2', 'QgsComposerView', 'QgsEncodingFileDialog', 'QgsFormAnnotationItem', 'QgsGenericProjectionSelector', 'QgsLegendInterface', 'QgsMapCanvas', 'QgsMapCanvasItem', 'QgsMapCanvasLayer', 'QgsMapCanvasMap', 'QgsMapCanvasSnapper', 'QgsMapOverviewCanvas', 'QgsMapTip', 'QgsMapTool', 'QgsMapToolEmitPoint', 'QgsMapToolPan', 'QgsMapToolZoom', 'QgsMessageViewer', 'QgsProjectBadLayerGuiHandler', 'QgsProjectionSelector', 'QgsQuickPrint', 'QgsRendererV2PropertiesDialog', 'QgsRendererV2Widget', 'QgsRubberBand', 'QgsStyleV2ManagerDialog', 'QgsSymbolLayerV2Widget', 'QgsSymbolV2PropertiesDialog', 'QgsSymbolV2SelectorDialog', 'QgsTextAnnotationItem', 'QgsVertexMarker', 'Qt', 'SIGNAL', '__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>> w = mywnd.MyWnd()
QWidget: Must construct a QApplication before a QPaintDevice
Abort trap


it give me a python crash ... obviously i'm missing something basilar,

have you any clue on what i need to change to have the example working outside qgis ?


thanks a lot !!!

regards,

Massimo



More information about the Qgis-developer mailing list