<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    From a quick look, maybe the destination CRS of the map canvas is
    missing.<br>
    <br>
    In a code, I used:<br>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; margin-top: 0px; margin-bottom: 0px; color: rgb(51, 51, 51); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="line" id="LC104" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">mMapCanvas</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">setCrsTransformEnabled</span><span class="p" style="box-sizing: border-box;">(</span> <span class="nb" style="box-sizing: border-box; color: rgb(0, 134, 179);">true</span> <span class="p" style="box-sizing: border-box;">);</spa
n></div><div class="line" id="LC105" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">mMapCanvas</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">setDestinationCrs</span><span class="p" style="box-sizing: border-box;">(</span> xxx <span class="p" style="box-sizing: border-box;">);</span></div><div class="line" id="LC106" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">mMapCanvas</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">refresh</span><span class="p" style="box-sizing: border-box;">();</span></div></pre>
    <br>
<a class="moz-txt-link-freetext" href="http://qgis.org/api/classQgsMapCanvas.html#ab7cb4f74b2c21b77783bd1f49f5878d8">http://qgis.org/api/classQgsMapCanvas.html#ab7cb4f74b2c21b77783bd1f49f5878d8</a><br>
    <br>
    Cheers,<br>
    <br>
    Denis<br>
    <br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 08.06.2014 12:49, Felix Schmidt
      wrote:<br>
    </div>
    <blockquote cite="mid:53943FB9.7020806@uni-weimar.de" type="cite">
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      Hello everyone, did anybody assorted my code and had an idea,
      where the problem can be located. I am so confused about the
      behavior of this plugin. The code you can also find on Github (<a
        moz-do-not-send="true" class="moz-txt-link-freetext"
        href="https://github.com/MenschMarcus/HiBo-plugin">https://github.com/MenschMarcus/HiBo-plugin</a>)<br>
      <br>
       hibo.py:<br>
      <br>
      # Import the PyQt and QGIS libraries<br>
      from PyQt4 import QtCore,  QtGui<br>
      from PyQt4.QtCore import * <br>
      from PyQt4.QtGui import *<br>
      from qgis.core import *<br>
      # Initialize Qt resources from file resources.py<br>
      import resources<br>
      import sys<br>
      import os<br>
      # Import the code for the dialog<br>
      from Ui_hibo import Ui_hibo<br>
      <br>
      class hibo: <br>
      <br>
          def __init__(self, iface):<br>
              # Save reference to the QGIS interface<br>
              self.iface = iface<br>
              self.gui = Ui_hibo ()<br>
          self.gui.setupUi()<br>
      <br>
          def connects(self):<br>
              #self.dlg.ui.load_button.clicked.connect(self.loadImage)<br>
              pass<br>
      <br>
          def initGui(self):  <br>
              # Create action that will start plugin configuration<br>
              self.action = QAction(QIcon("icon.png"), "HiBo",
      self.iface.mainWindow())<br>
              # connect the action to the run method<br>
              QObject.connect(self.action, SIGNAL("activated()"),
      self.run) <br>
      <br>
              # Add toolbar button and menu item<br>
              self.iface.addToolBarIcon(self.action)<br>
              self.iface.addPluginToMenu("&HiBo", self.action)<br>
      <br>
          def unload(self):<br>
              # Remove the plugin menu item and icon<br>
              self.iface.removePluginMenu("&HiBo",self.action)<br>
              self.iface.removeToolBarIcon(self.action)<br>
      <br>
          # run method that performs all the real work<br>
          def run(self): <br>
              # show the dialog<br>
              self.gui.show()<br>
          #print os.getcwd()<br>
              result = self.gui.exec_() <br>
              # See if OK was pressed<br>
              if result == 1: <br>
                  print "test1"<br>
      <br>
      ui_hibo.py:<br>
      <br>
      #!/usr/bin/python<br>
      # -*- coding: utf-8 -*-<br>
      <br>
      import sys<br>
      import os<br>
      <br>
      from PyQt4 import QtCore, QtGui<br>
      from PyQt4.QtCore import * <br>
      from PyQt4.QtGui import *<br>
      from qgis.core import *<br>
      from qgis.gui import *<br>
      <br>
      <br>
      try:<br>
          _fromUtf8 = QtCore.QString.fromUtf8<br>
      except AttributeError:<br>
          def _fromUtf8(s):<br>
              return s<br>
      <br>
      try:<br>
          _encoding = QtGui.QApplication.UnicodeUTF8<br>
          def _translate(context, text, disambig):<br>
              return QtGui.QApplication.translate(context, text,
      disambig, _encoding)<br>
      except AttributeError:<br>
          def _translate(context, text, disambig):<br>
              return QtGui.QApplication.translate(context, text,
      disambig)<br>
      <br>
      class Ui_hibo(QtGui.QDialog):<br>
              <br>
          def __init__(self): <br>
              QtGui.QDialog.__init__(self)<br>
          self.setupUi()<br>
      <br>
          #self.connect(self.loadRaster, QtCore.SIGNAL('triggered()'),
      self.loadRasterImage)<br>
          self.connect(self.canvasRaster,
      QtCore.SIGNAL('renderStarting()'), self.startRendering)<br>
      <br>
              self.setWindowTitle(self.tr("HiBo"))<br>
      <br>
          def setupUi(self):<br>
          """setup for toolbar"""<br>
          self.toolbarVector     = QtGui.QToolBar('vector', self)<br>
          self.toolbarRaster     = QtGui.QToolBar('raster', self)<br>
      <br>
          self.zoominVector     =
      QtGui.QAction(QtGui.QIcon("zoomin.png"), 'zoominVector', self)<br>
          self.zoomoutVector     =
      QtGui.QAction(QtGui.QIcon("zoomout.png"), 'zoomoutVector', self)<br>
          self.moveVector     = QtGui.QAction(QtGui.QIcon("move.png"),
      'moveVector', self)<br>
          self.loadVector     = QtGui.QAction(QtGui.QIcon("load.png"),
      'loadVector', self)<br>
          self.zoominRaster     =
      QtGui.QAction(QtGui.QIcon("zoomin.png"), 'zoominRaster', self)<br>
          self.zoomoutRaster     =
      QtGui.QAction(QtGui.QIcon("zoomout.png"), 'zoomoutRaster', self)<br>
          self.moveRaster     = QtGui.QAction(QtGui.QIcon("move.png"),
      'moveRaster', self)<br>
          self.loadRaster     = QtGui.QAction(QtGui.QIcon("load.png"),
      'loadRaster', self)<br>
          self.selectRaster    =
      QtGui.QAction(QtGui.QIcon("select.png"), 'selectRaster', self)   
      <br>
      <br>
          self.toolbarVector.addAction(self.loadVector)<br>
          self.toolbarVector.addAction(self.zoominVector)<br>
          self.toolbarVector.addAction(self.zoomoutVector)<br>
          self.toolbarVector.addAction(self.moveVector)<br>
          <br>
          self.toolbarRaster.addAction(self.loadRaster)    <br>
          self.toolbarRaster.addAction(self.zoominRaster)<br>
          self.toolbarRaster.addAction(self.zoomoutRaster)<br>
          self.toolbarRaster.addAction(self.moveRaster)<br>
          self.toolbarRaster.addAction(self.selectRaster)<br>
          <br>
          """setup for canvas"""<br>
          self.canvasVector    = QgsMapCanvas()<br>
         
      self.canvasVector.setCanvasColor(QtGui.QColor(255,255,255,255))<br>
          self.canvasVector.enableAntiAliasing(True)<br>
          self.canvasRaster    = QgsMapCanvas()<br>
         
      self.canvasRaster.setCanvasColor(QtGui.QColor(255,255,255,255))<br>
          self.canvasRaster.enableAntiAliasing(True)<br>
          <br>
          #fileName = QFileDialog.getOpenFileName(None, "historical
      map", ".", "Image Files (*.png *.jpg *.bmp *.tiff)")<br>
          fileName = "/home/felix/programming/HiBo-plugin/hibo/map.tif"<br>
              fileInfo = QFileInfo(fileName)<br>
              baseName = fileInfo.baseName()<br>
              rlayer = QgsRasterLayer(fileName, baseName)<br>
              if not rlayer.isValid():<br>
                  print "Layer failed to load!"<br>
              QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br>
          self.canvasRaster.setExtent(rlayer.extent())<br>
          self.canvasRaster.setLayerSet( [ QgsMapCanvasLayer(rlayer) ] )<br>
      <br>
          """layout"""<br>
          vectorarea     = QtGui.QWidget()<br>
          rasterarea     = QtGui.QWidget()<br>
      <br>
          layoutVector     = QtGui.QVBoxLayout()<br>
          layoutRaster     = QtGui.QVBoxLayout()<br>
      <br>
          vectorarea.setLayout(layoutVector)<br>
          rasterarea.setLayout(layoutRaster)<br>
      <br>
          layoutVector.addWidget(self.toolbarVector)<br>
          layoutVector.addWidget(self.canvasVector)<br>
          layoutRaster.addWidget(self.toolbarRaster)<br>
          layoutRaster.addWidget(self.canvasRaster)<br>
      <br>
          layoutCentral = QtGui.QHBoxLayout(self)<br>
          layoutCentral.addWidget(vectorarea)<br>
          layoutCentral.addWidget(rasterarea)    <br>
          <br>
          def retranslateUi(self):<br>
              self.setWindowTitle(_translate("hibo", "hibo", None))<br>
      <br>
          #here it loads only in the legend of qgis main window<br>
          """@QtCore.pyqtSlot()<br>
          def loadRasterImage(self):<br>
              #fileName = QFileDialog.getOpenFileName(None, "historical
      map", ".", "Image Files (*.png *.jpg *.bmp *.tiff)")<br>
          fileName = "/home/felix/programming/HiBo-plugin/hibo/map.tif"<br>
              fileInfo = QFileInfo(fileName)<br>
              baseName = fileInfo.baseName()<br>
              rlayer = QgsRasterLayer(fileName, baseName)<br>
              if not rlayer.isValid():<br>
                  print "Layer failed to load!"<br>
              QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br>
          self.canvasRaster.setExtent(rlayer.extent())<br>
          self.canvasRaster.setLayerSet( [ QgsMapCanvasLayer(rlayer) ] )<br>
          #self.canvasRaster.refresh()"""<br>
      <br>
          @QtCore.pyqtSlot()<br>
          def startRendering(self):<br>
          print "start rendering"<br>
      <br>
      <br>
      <br>
      <div class="moz-cite-prefix">Am 06.06.2014 07:40, schrieb Denis
        Rouzaud:<br>
      </div>
      <blockquote cite="mid:5391543D.2020305@gmail.com" type="cite">
        <meta content="text/html; charset=UTF-8"
          http-equiv="Content-Type">
        can you maybe show us the whole code?<br>
        <br>
        Cheers,<br>
        <br>
        Denis<br>
        <br>
        <div class="moz-cite-prefix">On 05.06.2014 20:55, Felix Schmidt
          wrote:<br>
        </div>
        <blockquote cite="mid:5390BD3E.8070004@uni-weimar.de"
          type="cite">
          <meta content="text/html; charset=UTF-8"
            http-equiv="Content-Type">
          The layer is loading in the legend and shown in the main
          window. <br>
          What do you mean, with the symbology. In front of the layer,
          in the legend, is a raster icon, if you mean this.<br>
          <br>
          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. <br>
          <br>
          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. <br>
          <br>
          It's confusing me.<br>
          <br>
          Felix <br>
          <br>
          <div class="moz-cite-prefix">Am 05.06.2014 20:20, schrieb Tim
            Sutton:<br>
          </div>
          <blockquote
cite="mid:CALCNqkaoOPXdih_=6Gxv206f-rWwyjVjaT=i=CpuATFR7obB5g@mail.gmail.com"
            type="cite">
            <div dir="ltr">Hi
              <div><br>
              </div>
              <div class="gmail_extra"><br>
                <br>
                <div class="gmail_quote">On Fri, Jun 6, 2014 at 12:15
                  AM, Felix Schmidt <span dir="ltr"><<a
                      moz-do-not-send="true"
                      href="mailto:felix.schmidt@uni-weimar.de"
                      target="_blank">felix.schmidt@uni-weimar.de</a>></span>
                  wrote:<br>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">Same

                    mistake with refresh() at the end.<br>
                    <br>
                    Am 05.06.2014 19:11, schrieb Rouzaud Denis:
                    <div class="HOEnZb">
                      <div class="h5"><br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          self.canvasRaster.refresh() at the end ?<br>
                          <br>
                          On 05 Jun 2014, at 18:27, Felix Schmidt <<a
                            moz-do-not-send="true"
                            href="mailto:felix.schmidt@uni-weimar.de"
                            target="_blank">felix.schmidt@uni-weimar.de</a>>



                          wrote:<br>
                          <br>
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex"> <br>
                            <br>
                            <br>
                            Hello everyone,<br>
                            I try to load on signal, a rasterlayer to
                            qgsmapcanvas. I try it like in<br>
                            the pycookbook:<br>
                            <br>
                            @QtCore.pyqtSlot()<br>
                                 def loadRasterImage(self):<br>
                                 print "slot works"<br>
                                     fileName =
                            QFileDialog.getOpenFileName(None,
                            "historical map",<br>
                            ".", "Image Files (*.png *.jpg *.bmp
                            *.tiff)")<br>
                                     fileInfo = QFileInfo(fileName)<br>
                                     baseName = fileInfo.baseName()<br>
                                     rlayer = QgsRasterLayer(fileName,
                            baseName)<br>
                                     if not rlayer.isValid():<br>
                                         print "Layer failed to load!"<br>
                                   
                             QgsMapLayerRegistry.instance().addMapLayer(rlayer)<br>
                                 print rlayer.extent().yMinimum()<br>
                               
                             self.canvasRaster.setExtent(rlayer.extent())<br>
                                 self.canvasRaster.setLayerSet( [
                            QgsMapCanvasLayer(rlayer) ] )<br>
                            <br>
                            self.canvasRaster is defined in the gui . I
                            search for 8h but I dont<br>
                            find a solutionen, because there are no
                            errors.<br>
                            <br>
                            It load the rasterlayer to the main program
                            of qgis, but not in my<br>
                            qgsmapcanvas. it is still white.<br>
                            <br>
                          </blockquote>
                        </blockquote>
                      </div>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>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.</div>
                  <div><br>
                  </div>
                  <div>Regards</div>
                  <div><br>
                  </div>
                  <div>Tim</div>
                  <div> </div>
                  <blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
                    <div class="HOEnZb">
                      <div class="h5">
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <blockquote class="gmail_quote"
                            style="margin:0 0 0 .8ex;border-left:1px
                            #ccc solid;padding-left:1ex"> please help
                            me.<br>
                            <br>
                            Felix<br>
                            <br>
                            <br>
                            <br>
_______________________________________________<br>
                            Qgis-developer mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:Qgis-developer@lists.osgeo.org"
                              target="_blank">Qgis-developer@lists.osgeo.org</a><br>
                            <a moz-do-not-send="true"
                              href="http://lists.osgeo.org/mailman/listinfo/qgis-developer"
                              target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
                          </blockquote>
                        </blockquote>
                        <br>
                        _______________________________________________<br>
                        Qgis-developer mailing list<br>
                        <a moz-do-not-send="true"
                          href="mailto:Qgis-developer@lists.osgeo.org"
                          target="_blank">Qgis-developer@lists.osgeo.org</a><br>
                        <a moz-do-not-send="true"
                          href="http://lists.osgeo.org/mailman/listinfo/qgis-developer"
                          target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
                      </div>
                    </div>
                  </blockquote>
                </div>
                <br>
                <br clear="all">
                <div><br>
                </div>
                -- <br>
                <div dir="ltr">Tim Sutton - QGIS Project Steering
                  Committee Member<br>
                  ==============================================<br>
                  Please do not email me off-list with technical<br>
                  support questions. Using the lists will gain<br>
                  more exposure for your issues and the knowledge<br>
                  surrounding your issue will be shared with all.<br>
                  <br>
                  Irc: timlinux on #qgis at <a moz-do-not-send="true"
                    href="http://freenode.net" target="_blank">freenode.net</a><br>
                  ==============================================</div>
              </div>
            </div>
          </blockquote>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
  </body>
</html>