1

I am trying to make a QGIS plugin using Python. Right now I need way add an image to canvas but I don't want that image to be a new layer in qgis project. Is there a way to do it?

Now I have:

self.canvas = qgis.gui.QgsMapCanvas() 
self.canvas.show()

But it shows only white rectangle.

2

As Luigi anwered:

self.canvas.scene().addItem(...) 

adds image to the canvas. Thanks!

1

a QgsMapCanvas is a QGraphicsView so you can add graphics items as usual in the scene of this class QGraphicsScene

regards

  • I am afraid I dont get it. self.canvas.addItem(name) results in AttributeError: 'QgsMapCanvas' object has no attribute 'addItem' – Bajzel May 13 '15 at 15:37
  • 1
    the scene has addItem method! self.canvas.scene().addItem(...) – Luigi Pirelli May 13 '15 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.