Gradient in pdf

  • Good day. Noticed such a thing. If I draw to pdf any shape with a gradient fill, the fill becomes a picture. If a shape to fill a solid color, it will be a vector object.
    I understand that to use native gradient, we need to define USE_NATIVE_GRADIENTS, but in qprintengine_pdf_p.h this definition commented.
    Why is it done? Native gradient somehow reflects badly on the pdf file? Or maybe someone knows how to put pdf native gradient?

    Code example:
    @int main(int argc, char *argv[])
    QApplication a(argc, argv, false);

    QPrinter printer;
    QRect rect(printer.width()/3, printer.height()/3,
               printer.width()/3, printer.height()/3);
    QList<QBrush> brushs;
    QLinearGradient gradient(rect.topLeft(), rect.bottomRight());
    gradient.setColorAt(0.0, Qt::white);
    gradient.setColorAt(1.0, Qt::green);
    for (int i = 0; i < brushs.count(); ++i)
        QPainter painter(&printer);
    return 0;


    P.S. used Qt 4.8.1, 4.8.5, 4.8.6

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.