[PyKDE] printing crashes application (segmentation fault)

Katja Wegner k.wegner at herts.ac.uk
Mon Sep 4 09:59:55 BST 2006


Hi,

I use PyQt4 bindings. I just ported my GUI from Qt3 to Qt4.
The GUI always crashes when the program calls the drawImage(image) method
of the QPainter object for the printing process.  I saved the image and 
it looked
good. Since it is similar to the example in the "C++ Gui Programming 
with Qt4"
book and I don't get any error messages, I don't know what the problem is.

Thanks for your help.
Katja

###########################

My printing method:

printDialog = QPrintDialog(self.printer, self)
if printDialog.exec_():
   printerPainter = QPainter(self.printer)

   # create an image of the current model
   image = self.createImage(self.modelWidth, self.modelHeight)

   # rescale the image according to printer settings
   printerRect = printerPainter.viewport()
   imageSize = image.size()
   imageSize.scale(printerRect.size(), Qt.KeepAspectRatio)

   # print image
   printerPainter.setViewport(printerRect.x(), printerRect.y(), 
imageSize.width(), imageSize.height())
   printerPainter.setWindow(image.rect())
   #image.save("/home/katja/saveTest.jpg", "JPG")

   # without the following line everything works fine
   printerPainter.drawImage(0, 0, image)
   printerPainter.end()




More information about the PyQt mailing list