Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.10
-
None
Description
Currently we duplicate the print/printToPdf API across QWebEngineView, Page, and Frame. This means a lot of locations where settings/APIs need to be updated and documented. There is also an issue that the QPrinter side of the API is dependent on QWidgets so it can't (or just isn't?) provided on Page/Frame.
We also have other limitations like only one print job at a time, no reason given for printing failure, some exceptional cases where callbacks aren't invoked...
A different approach might be to create a more token-like PrintJob object, with the settings as a separate object for ease of configuration. Something like:
struct QWebEnginePrintJobSettings { /* layout, margins, etc. */ }; class QWebEnginePrintJob { Q_GADGET public: enum Status { Working, Cancelled, Failed, Finished, }; // Printing begins at construction time QWebEnginePrintJob(QWebEnginePage* page, QWebEnginePrintJobSettings settings = {}); #if widgets_enabled QWebEnginePrintJob(QWebEnginePage* page, QPrinter* printer); #endif // frame overloads void start(); Status status() const; void cancel(); signals: void statusChanged(Status status); // one of finished/failed is always emitted void finished(QSharedPointer<QByteArray> data); // user saves file themself void failed(QString reason); };