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@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer