Good day.
Again as a note.
There was a need to print an exact copy of the contents of QTableWidget with delegates, etc.
It turned out the following:
void FinalPage::on_pushButtonPrint_clicked() { int width = 0; int height = 0; int columns = ui->tableWidgetName->columnCount(); int rows = ui->tableWidgetName->rowCount(); for( int i = 0; i < columns; ++i ) { width += ui->tableWidgetName->columnWidth(i); } for( int i = 0; i < rows; ++i ) { height += ui->tableWidgetName->rowHeight(i); } ui->tableWidgetName->setFixedSize(width, height); ui->tableWidgetName->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui->tableWidgetName->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QPrintPreviewDialog *prDialog = new QPrintPreviewDialog(&printer, this); ui->tableWidgetName->render(&printer); connect(prDialog,&QPrintPreviewDialog::paintRequested,this,&FinalPage::printPreviewNeeds); prDialog->showMaximized(); prDialog->exec(); } void FinalPage::printPreviewNeeds(QPrinter *) { ui->tableWidgetName->render(&printer); }