report->dataManager()->addModel("TreeWidget", ui->tableWidget->model(), false);
add item to QTableWidget====================const QString id = QString::number(ui->spinBox_id->value()); const QString name = ui->lineEdit_name->text(); const QString year = ui->lineEdit_year_work->text(); const QString salary = QString::number(ui->doubleSpinBox_salary->value()); const int rowCount = ui->tableWidget->rowCount(); ui->tableWidget->insertRow(rowCount); ui->tableWidget->setItem(rowCount, ID, new QTableWidgetItem(id)); ui->tableWidget->setItem(rowCount, Name, new QTableWidgetItem(name)); ui->tableWidget->setItem(rowCount, Year, new QTableWidgetItem(year)); ui->tableWidget->setItem(rowCount, Salary, new QTableWidgetItem(salary)); // clear content of widgets ui->spinBox_id->clear(); ui->lineEdit_name->clear(); ui->lineEdit_year_work->clear(); ui->doubleSpinBox_salary->clear();
when a "Show Report" buttun click========================= m_report.dataManager()->addModel("TreeWidget", ui->tableWidget->model(), false); m_report.loadFromFile(":/report/res/m_report.lrxml");m_report.previewReport();