I have to print on plotter world map with a lot of vector data on it from Qt based app. Plotter has 80 GB hard drive, to print high resolution images. All data is loaded in QGraphicsScene.
QGraphicsScene *scene;
.....
QPrinter *printer = new QPrinter(QPrinter::ScreenResolution);
printer->setPaperSize(QPrinter::A4);
QPainter painter(printer);
painter.setRenderHint(QPainter::Antialiasing);
A4 is using for improve speed during tests.
forever
{
if(printedHeight >= sceneHeight)
{
isPrintingRunning = false;
qDebug() << "Printing finished";
break;
}
...loading next tile strip
scene->render(&painter, toPage(sceneRect), tileStripRect);
scene->clearStrip;
printedHeight += stripHeight;
}
After loading vector data, i'm loading tiles(256x256 px) by horizontal strips, render strip to painter, clear tiles from scene, than again. Because i'm rendering by strips scene doesn't exceed available memory, but QPainter doesn't send data to printer until it will be deleted, that's why my app very quickly run out of memory. There is an opportunity to call QPainter::end() each cycle step, but in this way each strip is printed on differrent page on ordinary printer, so I suppose plotter will cut each strip, as soon as i can't control plotter's knife. So this is not a solution. How can I force QPainter to send data and clear its cache, but stay in the same print session?