I'm developing a plugin that will enable the grid decorations(like copyright, scale bar) on the map canvas, but I don't find any clue on how to do it.

Just to clarify I don't want to create a grid inside a layer, I just want to enable the decorations grid as shown in the image below.

enter image description here

I've searched in the QGIS GUI and QgsMapCanvas API without any luck.

  • To draw the grid QGIS uses theQgsDecorationGrid class which is not exposed through the API. A workaround is well explained in this answer. Here is another link to give you an idea of which project entries you need to write to enable the grid: github.com/qgis/QGIS/blob/master/src/app/decorations/…
    – CodeBard
    Mar 15, 2022 at 15:40
  • Thanks, @CodeBard, but the approach on the answer works when I save and reload the project. I need a workaround like in the cheat sheet, but for the QgsDecorationGrid. Unfortunately, I don't find yet what do I have to override in the grid render method to enable the grid without reloading the project. Mar 16, 2022 at 12:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.