[Qgis-developer] add rasterlayer to qgsmapcanvas

Felix Schmidt felix.schmidt at uni-weimar.de
Thu Jun 5 11:55:58 PDT 2014


The layer is loading in the legend and shown in the main window.
What do you mean, with the symbology. In front of the layer, in the 
legend, is a raster icon, if you mean this.

I copied the code from the slot to the building of the ui. so the layer 
is loading in the canvas by building the gui and not by clicking in the 
toolbar.

If I start qgis with this state of code, its starts and load load the 
layer, when I start the plugin the canvas is still white and when I 
clicked on the starting picture of qgis which is still there, the layer 
is shown in the canvas of the plugin.

It's confusing me.

Felix

Am 05.06.2014 20:20, schrieb Tim Sutton:
> Hi
>
>
>
> On Fri, Jun 6, 2014 at 12:15 AM, Felix Schmidt 
> <felix.schmidt at uni-weimar.de <mailto:felix.schmidt at uni-weimar.de>> wrote:
>
>     Same mistake with refresh() at the end.
>
>     Am 05.06.2014 19:11, schrieb Rouzaud Denis:
>
>         self.canvasRaster.refresh() at the end ?
>
>         On 05 Jun 2014, at 18:27, Felix Schmidt
>         <felix.schmidt at uni-weimar.de
>         <mailto:felix.schmidt at uni-weimar.de>> wrote:
>
>
>
>
>             Hello everyone,
>             I try to load on signal, a rasterlayer to qgsmapcanvas. I
>             try it like in
>             the pycookbook:
>
>             @QtCore.pyqtSlot()
>                  def loadRasterImage(self):
>                  print "slot works"
>                      fileName = QFileDialog.getOpenFileName(None,
>             "historical map",
>             ".", "Image Files (*.png *.jpg *.bmp *.tiff)")
>                      fileInfo = QFileInfo(fileName)
>                      baseName = fileInfo.baseName()
>                      rlayer = QgsRasterLayer(fileName, baseName)
>                      if not rlayer.isValid():
>                          print "Layer failed to load!"
>                      QgsMapLayerRegistry.instance().addMapLayer(rlayer)
>                  print rlayer.extent().yMinimum()
>                  self.canvasRaster.setExtent(rlayer.extent())
>                  self.canvasRaster.setLayerSet( [
>             QgsMapCanvasLayer(rlayer) ] )
>
>             self.canvasRaster is defined in the gui . I search for 8h
>             but I dont
>             find a solutionen, because there are no errors.
>
>             It load the rasterlayer to the main program of qgis, but
>             not in my
>             qgsmapcanvas. it is still white.
>
>
> Is the layer loaded, showing in the legend but just not visible? Check 
> the symbology for the layer is defined properly if this is the case.
>
> Regards
>
> Tim
>
>             please help me.
>
>             Felix
>
>
>
>             _______________________________________________
>             Qgis-developer mailing list
>             Qgis-developer at lists.osgeo.org
>             <mailto:Qgis-developer at lists.osgeo.org>
>             http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>     _______________________________________________
>     Qgis-developer mailing list
>     Qgis-developer at lists.osgeo.org <mailto:Qgis-developer at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
>
> -- 
> Tim Sutton - QGIS Project Steering Committee Member
> ==============================================
> Please do not email me off-list with technical
> support questions. Using the lists will gain
> more exposure for your issues and the knowledge
> surrounding your issue will be shared with all.
>
> Irc: timlinux on #qgis at freenode.net <http://freenode.net>
> ==============================================

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140605/c8b9013b/attachment.html>


More information about the Qgis-developer mailing list