[Qt-interest] Difference in drawing to a QPixmap VS QPrinter

Samuel Gaist samuel.gaist at cinetis.ch
Fri Jul 2 14:14:49 CEST 2010


On 2 juil. 10, at 14:01, Christopher Rasch-Olsen Raa wrote:

> Hi,
>
> A requirement for an application I'm working on is that it should  
> write a
> certain page of text to a .pdf. For that I'm using QPainter with  
> QPrinter and
> setting the outputformat to Pdf. All is good so far.
>
> However, another requirement is that the application should be able  
> to display
> a "preview" of the document. I though that the quickest way to  
> achieve that
> must be to pass a QPixmap to the QPainter (since QPixmap is a  
> paintdevice) and
> let the same code for painting do it's thing regardless for the  
> 'medium'.
>
> What happens is that I get wildly varying looks on the two  
> documents. The pdf
> looks fine(-ish. lacking some tweaks) but the image (QPixmap) does  
> not. In the
> QPixmap the text is way too large.
>
> I use (pixmap/printer)->width() and ->height() to get the width and  
> height of
> my 'canvas' and position things relative to the edges. When creating  
> the fonts
> I pass the 'device' (a pixmap or printer) to the font's constructor.  
> Is the
> something special I need to do to have the font 'scale' in  
> accordance to the
> size of the available 'canvas'?
>
> Have anyone done this before and have some insight to share?
>
> -- 
> Christopher
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

Hi,

I can not help you directly for the QPixmap problem but for what you  
want to achieve you might be interested by QPrintPreviewWidget or  
QPrintPreviewDialog.

Hope this helps
Samuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1587 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100702/c10b3de4/attachment.bin 


More information about the Qt-interest-old mailing list