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

QWidget::render() cannot render TableWidget to pdf correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.9.0
    • None
    • Windows

    Description

      I want to output the full widget to a pdf file, so I use the QWidget::render() method.

      Here's my code:

      QPdfWriter pw("D://test.pdf");
      QPainter pt;
      pt.begin(&pw);
      ui->tableWidget->render(&pt);
      pt.end();

      The reason for using QPdfWriter is that I want the pdf to be vectorized,so I did not use QPrinter.

      So here's my question:

      If the horizontal headerView  and the vertical headerView of the QTableWidget is visible,

      Then the table will be incomplete in the pdf file, and the format will be confused or missing.

      Similarly, the same problem occurs if the table has a cell merge operation.

       

      Here is the correct format:

      Below is the exported pdf file:

       

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            jcqter wang wenchao
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes