Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-136002

Create PrintJob/PrintRequest object

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.10
    • WebEngine
    • 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);
      };

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            moheim Moss Heim
            moheim Moss Heim
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes