Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Gradient in pdf
Qt 6.11 is out! See what's new in the release blog

Gradient in pdf

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 954 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lemma
    wrote on last edited by
    #1

    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;
    printer.setColorMode(QPrinter::Color);
    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);
    
    brushs.append(QBrush(gradient));
    brushs.append(QBrush(Qt::green));
    
    for (int i = 0; i < brushs.count(); ++i)
    {
        printer.setOutputFileName(QString("output%1.pdf").arg(i));
    
        QPainter painter(&printer);
        painter.setBrush(brushs.at(i));
        painter.drawEllipse(rect);
        painter.end();
    }
    
    return 0;
    

    }@

    P.S. used Qt 4.8.1, 4.8.5, 4.8.6

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved