Search code examples
pdfqtwebkit

using QtWebkit headless in Qt GUI app


i need to use Qtwebkit functions in GUI application but i do not want to view the webkit in my GUI app. the main function is to render HTML to pdf . i know i can do it with QtWebkit headless.


Solution

  • Use QWebPage since it can work without displaying anything on the screen. Something like:

    QPrinter printer;
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName(fileName);
    
    page->mainFrame->print(&printer);