I wrote a program to experiment with poppler pdf library. I am able to display pdf pages into a graphicsView with a method:
void MainWindow::setPage(int newpage)
{
pdfPage = document->page(newpage);
if (pdfPage == 0) {
// ... error message ...
return;
}
// Generate a QImage of the rendered page
image = pdfPage->renderToImage(100.0,100.0,0,0,pdfPage->pageSize().width(),pdfPage->pageSize().height());
if (image.isNull()) {
// ... error message ...
return;
}
pixmap=QPixmap::fromImage(image);
scene->clear();
scene->addPixmap(pixmap);
this->ui->graphicsView->setScene(scene);
this->ui->graphicsView->repaint(); //the same with show(), invalidate scene()
// after the usage, the page must be deleted
delete pdfPage;
}
with single call or in a slot for a control but if I write a cycle like for (i=0;i<200;i++) { setPage(i);} nothing is displayed until the cycle gets to its end, and then just the last page is visible. What's wrong? I tried with msleep(500) in a custom thread class, and tried also calling paintEvent for graphicsView. Can help?