Rather than drag guides onto a print composer, I would like to type in a number to set them at a specific point. Is it possible to do this?

E.g. I want to make sure I snap objects to margin guides at 10mm from the page edges. It's fiddly to use the mouse and I would have to zoom it to see enough markings on the ruler.

3 Answers 3


There's no way to do it in the GUI, but a little bit of PyQGIS will get you there:

from PyQt4.QtCore import QLineF

#get composition
c = iface.activeComposers()[0].composition()

margin = 10.0

#top guide
c.addSnapLine().setLine( QLineF( 0, margin, c.paperWidth(), margin))

#bottom guide
c.addSnapLine().setLine( QLineF( 0, c.paperHeight() - margin, c.paperWidth(), c.paperHeight() - margin))

#left guide
c.addSnapLine().setLine( QLineF( margin, 0, margin, c.paperHeight() ))

#right guide
c.addSnapLine().setLine( QLineF( c.paperWidth() - margin, 0, c.paperWidth() - margin, c.paperHeight()))

Note that if you have more than one composer you'll need to modify the c = iface.activeComposers()[0].composition() line to reflect the correct composer number (eg activeComposers()[1],...)


I use Inkscape as the final renderer for QGIS maps that need a bit more than can be found in the Print Composer - which is fine as many cartographers take maps out to Adobe Illustrator for final touch-ups...

The key is to create your layout in Inkscape, setting the guides where you want them, drawing a rectangle that snaps to your guides, and getting the dimensions of that rectangle back to the size of your print composer in QGIS.

Then you can export your map from QGIS as PNG or other format (ensuring your resolution is what you want depending on your application) and drop it right into your Inkscape layout.

Is this an extra step? Yes... but you can use your Inkscape and QGIS templates usefully if you're doing this a lot, or you have situations like we do where in addition to needing accurate guide placement, we need to manage text external to the map that is best done in a graphics package anyway... I made a map this morning using this method and it looks great!

But... to have this in QGIS core would be nice...


You have to open your .qgis file in a text editor to position guide lines exactly. The x and y values can be found in the 'SnapLine' tags.

See also: http://hub.qgis.org/issues/13950

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.