#include <QCoreApplication>
#include <QtPrintSupport/QPrinter>
#include <QLinearGradient>
#include <QPainter>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QPrinter printer;
    printer.setOutputFileName("print.pdf");
    printer.setOutputFormat(QPrinter::PdfFormat);

    QPainter painter(&printer);
    painter.setRenderHints(QPainter::Antialiasing, false);
    QLinearGradient grad(0.0f, 0.0f, 0.0f, 90.0f);
    grad.setColorAt(0.0f, Qt::blue);
    grad.setColorAt(1.0f, Qt::white);

    QPen scalePen(grad, 2);
    painter.setPen(scalePen);
    painter.scale(1.337, 1.337);
    painter.drawLine(QPointF(10, 10), QPointF(100, 100));
    painter.end();
    return a.exec();
}
