How do I display a 2D numpy.ndarray
as a collection of pixel values on a QGraphicsView
? pylab.imshow()
would typically be used at this point if I wasn't trying to make a GUI.
frame = array([[ 56., 57., 58., ..., 58., 58., 58.],
[ 52., 58., 58., ..., 56., 57., 59.],
[ 56., 55., 58., ..., 57., 57., 58.],
...,
[ 53., 55., 55., ..., 54., 54., 53.],
[ 54., 57., 56., ..., 53., 54., 59.],
[ 55., 57., 54., ..., 56., 58., 57.]])
My attempt:
scene = QGraphicsScene(self)
scene.addPixmap(QPixmap.fromImage(qimage2ndarray.array2qimage(frame)))
view = self.graphicsView(scene, self) # Error from this line
self.graphicsView = QtGui.QGraphicsView(scene, self)
view.show()
TypeError: 'QGraphicsView' object is not callable
. I want to specifically add the scene to the QGraphicsView
named graphicsView
that was generated by QT Designer. If I replace the line causing the error with the following
view = QtGui.QGraphicsView(scene, self)
Then the image displays, but in the top left of the QMainWindow
on top of my other widgets. How do I restrict placement to a specific QGraphicsView
?