Back to Blog home

Printing love

Published on Wednesday September 19, 2007 by Thomas Zander in Qt KDE | Comments

Being able to do good printing one of those requests that come up very often. probably more often then "World peace" and "How to avoid hangovers after drinking too much".
Like with world peace, the final answer is not going to be provided for quite some years yet. The topic is just too complex for one mind to answer (and we have some great minds in our communities). Now, we generally avoid the question altogether and just go and struggle though the headaces, which is mostly ok.

I'm often the perfectionist of the herd, aiming for the correct long-term solution. That helps with open source apps like KOffice2 which has seen a long development cycle which is really starting to pay off. My next bullet point is to give printing the love it deserves. And the printing code has been lonesome.

We are on a path of improvements, and I'm quite happy to see a constant set of improvements in Qt for printing. Which will mean a lot of applications out there will improve at the same time.
Qt4 has introduced a way to print to PDFs directly from a QPrinter instance, which is a great step forward since we used to rely on apps like ghostview to convert from postscript. This was known to have various problems. People are starting to use this more and more. But it has made another problem more clearly an itch to scratch.
The second longest request must have been to allow us to set custom page sizes. For example to print an envelope instead of a whole A4. So I decided to scratch that itch, and today I committed this change which you will find in the Qt4.4 snapshots tonight. There are 2 new methods on QPrinter. Namely; QPrinter::setPaperSize(Unit unit, QSizeF size) and QSizeF paperSize(Unit unit);
You can now do something like;

myPrinter.setPaperSize(QPrinter::Millimeter, QSizeF(162, 114));

Work is ongoing for printing, any feedback appreciated!

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.

The blog comment system has been migrated to a new platform. If you face any issues, please let us know via feedback@qt.io.