41
Discussion | Обсуждение / Re: How to set QTableView data to the limereport file lrxml
« Last post by Arin Alex on June 07, 2024, 04:54:08 pm »Hi. You have to set datasource property on the databand that will point to the data source
Hi!thank you, I tried and succeeded , I saw the model in the data sources panel, and When I tried with columns, it shows only the first item of the model, how can I achieve this to show all items which I set with qt created app.
QTableView dot't store any data it's own.
The data exists in the model.
This model You have been added to report.
Now You can just callCode: [Select]report->designReport()
to show LRDesigner, and your model must be shown in datasources
report->designReport()
to show LRDesigner, and your model must be shown in datasources ------
std::unique_ptr<QSqlQuery> _query;
std::unique_ptr<QSqlQuery> _query_sub;
QSqlDatabase _db;
------
_query = std::make_unique<QSqlQuery>( _db );
_query->prepare( "select * from tab1");
_query->exec();
QSqlQueryModel* customersModel = new QSqlQueryModel();
customersModel->setQuery( *_query );
_reportEngine->dataManager()->addModel( "tab1", customersModel, true );
_query_sub = std::make_unique<QSqlQuery>(_db);
_query_sub->prepare( "select * from tab2 where tab2.id == "$D{tab1.id}");
_query_sub->exec();
QSqlQueryModel* customersModelSub = new QSqlQueryModel();
customersModelSub->setQuery(*_query_sub);
_reportEngine->dataManager()->addModel("tab2", customersModelSub, false);