title: Plot image in pyqt graphicsView using pyQtGraph
body: <p>I tried reverse engineering the <a href="https://github.com/pyqtgraph/pyqtgraph/commit/4e9e75817fb0d2b5f6880278857621af30d7d0f1" rel="nofollow noreferrer">designerExample</a> to get it doing the same thing that it does for a plot, but for an image but get two results, neither correct:</p>
  
  <ol>
  <li>If I promote my <code>QGraphicsView</code> to <code>GraphicsView</code> I get the image
  outputted but it is not movable or zoomable as you would expect from
  items in pyQtGraph (Run the <a href="http://www.pyqtgraph.org/documentation/introduction.html#examples" rel="nofollow noreferrer">examples</a> script - I'm expecting similar behaviour to the <strong>GraphicsLayout</strong> example: there is an image in the grid in this example that is movable. Mine isn't even though I based my code off of this example)</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/nU0fN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nU0fN.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/zmAAk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zmAAk.png" alt="enter image description here"></a></p>
  
  <ol start="2">
  <li>If I promote my <code>QGraphicsView</code> to <code>GraphicsLayoutWidget</code> I get
  <code>AttributeError: 'QGraphicsView' object has no attribute 'addItem'</code>
  which I can see in the debugger. However, what I cant see is in the
  debugger is the GraphicsView attribute that <a href="http://www.pyqtgraph.org/documentation/widgets/graphicslayoutwidget.html#pyqtgraph.GraphicsLayoutWidget" rel="nofollow noreferrer">the
  GraphicsLayoutWidget should have</a>. Also, the <code>GraphicsView</code> also
  doesn't have an addItem attribute, at least not according to what I
  can see when I navigate to <code>ui.graphicsView</code> in the debugger with the
  breakpoint set to just before the call to <code>addItem(img)</code></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>import sys, os
  import pyqtgraph as pg
  import numpy as np
  from PyQt4.QtGui import *
  
  ## Define main window class from template
  path = os.path.dirname(os.path.abspath(__file__))
  uiFile = os.path.join(path, 'pyQtGraphTest.ui')
  WindowTemplate, TemplateBaseClass = pg.Qt.loadUiType(uiFile)
  
  class QMainWindow(TemplateBaseClass):
      def __init__(self):
          #super(QtGui.QMainWindow, self).__init__(parent)
          TemplateBaseClass.__init__(self)
  
          self.ui = WindowTemplate()
          self.ui.setupUi(self)
          self.ui.pushButton.clicked.connect(self.do_it)
  
      def do_it(self):
          frame = np.random.normal(size=(100,100))
          img = pg.ImageItem(frame)
          self.ui.graphicsView.addItem(img) #BREAKPOINT HERE
  
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
  
      form = QMainWindow()
      form.show()
      app.exec_()
  </code></pre>
  
  <p>pyQtGraphTest.ui</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ui version="4.0"&gt;
   &lt;class&gt;MainWindow&lt;/class&gt;
   &lt;widget class="QMainWindow" name="MainWindow"&gt;
    &lt;property name="geometry"&gt;
     &lt;rect&gt;
      &lt;x&gt;0&lt;/x&gt;
      &lt;y&gt;0&lt;/y&gt;
      &lt;width&gt;632&lt;/width&gt;
      &lt;height&gt;614&lt;/height&gt;
     &lt;/rect&gt;
    &lt;/property&gt;
    &lt;property name="windowTitle"&gt;
     &lt;string&gt;MainWindow&lt;/string&gt;
    &lt;/property&gt;
    &lt;widget class="QWidget" name="centralwidget"&gt;
     &lt;widget class="QPushButton" name="pushButton"&gt;
      &lt;property name="geometry"&gt;
       &lt;rect&gt;
        &lt;x&gt;10&lt;/x&gt;
        &lt;y&gt;10&lt;/y&gt;
        &lt;width&gt;99&lt;/width&gt;
        &lt;height&gt;27&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
      &lt;property name="text"&gt;
       &lt;string&gt;PushButton&lt;/string&gt;
      &lt;/property&gt;
     &lt;/widget&gt;
     &lt;widget class="GraphicsView" name="graphicsView"&gt;
      &lt;property name="geometry"&gt;
       &lt;rect&gt;
        &lt;x&gt;20&lt;/x&gt;
        &lt;y&gt;50&lt;/y&gt;
        &lt;width&gt;571&lt;/width&gt;
        &lt;height&gt;501&lt;/height&gt;
       &lt;/rect&gt;
      &lt;/property&gt;
     &lt;/widget&gt;
    &lt;/widget&gt;
   &lt;/widget&gt;
   &lt;customwidgets&gt;
    &lt;customwidget&gt;
     &lt;class&gt;GraphicsView&lt;/class&gt;
     &lt;extends&gt;QGraphicsView&lt;/extends&gt;
     &lt;header&gt;pyqtgraph.h&lt;/header&gt;
    &lt;/customwidget&gt;
   &lt;/customwidgets&gt;
   &lt;resources/&gt;
   &lt;connections/&gt;
  &lt;/ui&gt;
  </code></pre>