Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Print QWebEngineView



  • good day
    I implement printing in my program, it is necessary to capture the current window and print
    If the program is deployed, then all the text on the tab is printed completely, but if you reduce the program window until the scroll appears, part of the text is not displayed on the printed sheet.

    Is there a solution for my problem?
    thanks

        m_WebEngineView = new QWebEngineView(ui->tabReport);
        QVBoxLayout* layout = static_cast<QVBoxLayout*>(ui->tabReport->layout());
        layout->insertWidget(0,m_WebEngineView);
    
    void MainWindow::on_act_print_triggered()
        {
        QPrinter printer(QPrinter::ScreenResolution);
        printer.setOrientation(QPrinter::Landscape);
        QPrintPreviewDialog preview(&printer, this);
        QPrintDialog *dlg = new QPrintDialog(&printer, this);
        if (m_WebEngineView->hasSelection())
        dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
        dlg->setWindowTitle(tr("Print Document"));
        if (dlg->exec() == QDialog::Accepted)
        ui->tabReport->render(&printer);
        delete dlg;
        }

Log in to reply