I am trying to Print an invoice using Qt. One of the features necessary to for an invoice is a table for this I have decided to use a QTabelWidget because I understand how to use them but I am receiving an error stating "no matching member function for call to 'render'". How can I remedy this issue and is it even possible to print a QTableView. My code is below
QPrinter Print;
Print.setPaperSize(QPrinter::A4);
Print.setOrientation(QPrinter::Landscape);
Print.setDuplex(QPrinter::DuplexAuto);
QTableWidget PrintTable;
PrintTable.setRowCount(ui->tableWidget_Invoice->rowCount());
PrintTable.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
PrintTable.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QTableWidgetItem *Product_CODE = new QTableWidgetItem;
QTableWidgetItem *Description = new QTableWidgetItem;
QTableWidgetItem *Unit_Price = new QTableWidgetItem;
QTableWidgetItem *Qty = new QTableWidgetItem;
QTableWidgetItem *Total_Price = new QTableWidgetItem;
for(int x =0; x<ui->tableWidget_Invoice->rowCount(); x++)
{
Product_CODE->setText(ui->tableWidget_Invoice->item(x, 2)->text());
Description->setText(ui->tableWidget_Invoice->item(x, 1)->text());
Unit_Price->setText(ui->tableWidget_Invoice->item(x, 3)->text());
Qty->setText(ui->tableWidget_Invoice->item(x, 0)->text());
Total_Price->setText(ui->tableWidget_Invoice->item(x, 4)->text());
PrintTable.setItem(x, 0, Product_CODE);
PrintTable.setItem(x, 1, Description);
PrintTable.setItem(x, 2, Unit_Price);
PrintTable.setItem(x, 3, Qty);
PrintTable.setItem(x, 4, Total_Price);
}
QHeaderView* header = PrintTable.horizontalHeader();
header->setSectionResizeMode(QHeaderView::Stretch);
PrintTable.render(Print);