[Qgis-developer] How to use QPixmap argument in saveAsImage()

Martin Dobias wonder.sk at gmail.com
Wed Mar 3 17:54:58 EST 2010

On Wed, Mar 3, 2010 at 5:56 PM, pfth <pfth at gmx.de> wrote:
> Hello Martin,
> I am just trying to use the code you posted within a plugin to save the map
> to a image file. I am getting a lot of crashes. Sometimes it crashes at
> "c.addItem(composerMap) ", sometimes it saves the file to disk and crashes
> afterwards... I don't know whats wrong.

Well, it's hard to help you without any further information.
- what qgis version? what platform?
- can you provide backtrace of the segfaults?
- have you tried to run the code from python console?

> How can I make the code run as or in my plugin? Currently I added the code
> to the run() function of my plugin.

Executing the code in run() function should be fine.

> And how can I modify it in order to print the map directly to a printer?

I think you just need to use QPrinter instead of QImage for the
output. But I haven't tried it myself...


More information about the Qgis-developer mailing list