I want to set QTableView data to Lime report, I tried with this code void MainWindow::loadJsonData()
{
QFile file(":/data/sample.json");
if (!file.open(QIODevice::ReadOnly))
{
qWarning("Couldn't open the file.");
return;
}
QByteArray data = file.readAll();
QJsonDocument document = QJsonDocument::fromJson(data);
QJsonArray jsonArray = document.array();
model->setColumnCount(3);
model->setHeaderData(0, Qt::Horizontal, "Name");
model->setHeaderData(1, Qt::Horizontal, "Age");
model->setHeaderData(2, Qt::Horizontal, "City");
for (const QJsonValue & value : jsonArray)
{
QJsonObject obj = value.toObject();
QList<QStandardItem *> items;
items.append(new QStandardItem(obj["name"].toString()));
items.append(new QStandardItem(QString::number(obj["age"].toInt())));
items.append(new QStandardItem(obj["city"].toString()));
model->appendRow(items);
}
}
void MainWindow::on_generateReportButton_clicked()
{
report->loadFromFile(":/reports/sample_report.lrxml");
report->dataManager()->addModel("jsonData", model, true);
report->previewReport();
}
but I don't know how to handle with limereport designer,