QWebEnginePage and printToPdf Qt 5.7 issue
Unsolved
General and Desktop
-
Hi guys… I’m trying to use this function with qt 5.7 beta
void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout)
but, I have a problem with it because I don’t know when the pdf generation has finished, it seem like the pdf generation is running on other thread and I can’t know when it’s finish.
does any one has any advise to do that? how Qt 5.7 notify that the pdf was generated successful or with error using this method?
regards
-
Yes, it runs in a separate thread. You have "2.5" choices:
- Upgrade to Qt 5.9, which has just added signal QWebEnginePage::pdfPrintingFinished .
- Use the Qt 5.7 QWebEnginePage::printToPdf(FunctorOrLambda resultCallback) overload which will call your own callback when it prints.
2.5 Use a QFileSystemwatcher to monitor for file creation. [I am not keen on this one, e.g.QFileSystemWatcher::fileChanged()
signal is probably(?) emitted as soon as file starts being written to rather than on writing completed.]
See also my post on this forum for possible issue when waiting for
printToPdf()
to complete.