Why the help document does not have a complete example of HTML? I think it's completely guesswork to use it. It seems that it's not completely compatible with html4
-
Hi
You mean like this ?
https://forum.qt.io/topic/78143/export-a-qtablewidget-in-pdf -
This post is deleted!
-
@duncan98
What about the accepted solution in https://stackoverflow.com/questions/45467942/how-can-i-print-a-qwidget-in-qt ? The point isQWidget::render()
to a painter/paint device which is the desiredQPrinter
. See https://doc.qt.io/qt-5/qtprintsupport-index.html#printing-widgets.If you decide you want to do it by generating an HTML document into a
QDocument
off theQTableWidget
after all, see alternatively e.g. https://stackoverflow.com/questions/56605601/using-qt5-how-can-i-print-a-qtablewidget-and-scale-a-table-to-fit-onto-one-side. I went for this approach off anyQTableView
/model with rows & columns myself, so it's generic, I can use stylesheets for printing, I can export to PDF/CSV/XLSX, etc. One issue about printing theQTableWidget
as-is is that you get e.g. the column widths/truncation etc. you see on the screen, which may not be desirable, depending on your usage.
21/25