[Qgis-developer] Not Rendering the Shapefile in Canvas - Blank
Noli Sicad
nsicad at gmail.com
Fri Sep 10 08:34:11 EDT 2010
Hi Cédric
I inserted self.canvas.refresh() as showed below but still a blank canvas.
~~~~~~~~
# Set up the map canvas layer set
cl = QgsMapCanvasLayer(layer)
layers = [cl]
self.canvas.setLayerSet(layers)
self.canvas.refresh()
~~~~~~~~~
Thanks.
Noli
On 9/10/10, Möri Cedric <Cedric.Moeri at bd.so.ch> wrote:
> Hi Noli
>
> seems you're missing self.canvas.refresh() at the end of your code.
>
> regards
> Cédric
>
> mit freundlichen Grüssen
>
> Cédric Möri
> GIS-Informatiker
>
> --
> Kanton Solothurn
> Bau- und Justizdepartement
> Amt für Geoinformation
> Rötistrasse 4
> 4501 Solothurn
>
> Telefon: +41 (0)32 627 24 75
> Telefax: +41 (0)32 627 22 14
> mailto:cedric.moeri at bd.so.ch
> http://www.agi.so.ch
>
>
> ----- Originalnachricht -----
> Von: "Noli Sicad" <nsicad at gmail.com>
> Gesendet: Fre, 10.9.2010 14:03
> An: qgis-developer <qgis-developer at lists.osgeo.org>
> Betreff: [Qgis-developer] Not Rendering the Shapefile in Canvas - Blank
>
> Hi,
>
> Is there any reason why the shapefile is not rendering in this code
> (below)? I tried several shapefiles and yet I am getting a white
> canvas or blank canvas without a render. I was able to open the
> shapefile and the form with mapcanvas are showing. Yet no render of
> the polygons - totally blank.
>
> self.canvas.setCanvasColor(Qt.white) <---- a White Canvas without
> render - BLANK
>
> Thanks. Noli
>
>
> ~~~~~~~~~~~~~~~~
> class ShapeViewer(QMainWindow, Ui_MainWindow):
>
> def __init__(self):
> QMainWindow.__init__(self)
>
> # Required by Qt4 to initialize the UI
> self.setupUi(self)
>
> # Set the title for the app
> self.setWindowTitle("ShapeViewer")
>
> # Create the map canvas
> self.canvas = QgsMapCanvas()
> self.canvas.useImageToRender(False)
> self.canvas.show()
>
> # Lay our widgets out in the main window using a
> # vertical box layout
> self.layout = QVBoxLayout(self.frame)
> self.layout.addWidget(self.canvas)
>
> # layout is set - open a layer
> # Add an OGR layer to the map
> file = QFileDialog.getOpenFileName(self,
> "Open Shapefile", ".", "Shapefiles (*.shp)")
> fileInfo = QFileInfo(file)
>
> # Add the layer
> layer = QgsVectorLayer(file, fileInfo.fileName(), "ogr")
>
> if not layer.isValid():
> return
>
> # Add layer to the registry
> QgsMapLayerRegistry.instance().addMapLayer(layer);
>
> # Set extent to the extent of our layer
> self.canvas.setExtent(layer.extent())
>
> # Set up the map canvas layer set
> cl = QgsMapCanvasLayer(layer)
> layers = [cl]
> self.canvas.setLayerSet(layers)
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> 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