I can't seem to add a picture to my composition using PyQGIS in Windows 8. My code is based on the example I found in this question. I've tried using .setPicturePath
and .setPictureFile
but none seem to work for me. Instead, my map shows a red 'x' where the arrow should appear. Since the question was answered 2 years ago, has this method been superseded?
My code is:
#Add north arrow
arrow = QgsComposerPicture(c)
arrow.setPicturePath("C:\Program Files\QGIS 2.18\apps\qgis\svg\arrows\Arrow_03")
arrow.setSceneRect(QRectF(0,0,10,10)) #Resize
arrow.setItemPosition(20,20)
c.addItem(arrow)
Ideally, I want to replace the path with QgsApplication.svgPaths()[0] + "\Arrow_03"
but I figured I should get it working with a hard coded path first