Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: how to print each row number in limereport? using QTableWidget as datasource  (Read 3821 times)

Proton Phoenix

  • Newbie
  • *
  • Posts: 15
    • View Profile
Hi this is the best reporting engine ever thank you really for your great work
, i have a question , so i have Qtablewidget which contain a 3 columns
i want to get each row number when reporting using limereport
is there any way to do that!
for example i want those numbers on limereport
when viewing data the numbers show up, the databind doesn't support more than one datasource
is there any solution !!

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
the simplest way it's using the variable & script system

Proton Phoenix

  • Newbie
  • *
  • Posts: 15
    • View Profile
the simplest way it's using the variable & script system



i did that but the variable won't change because datasource is QTableWidget!
so i need to search for a script to solve that !
Thank you bro

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
It's simple.

How you form the report?
by callback function?

Proton Phoenix

  • Newbie
  • *
  • Posts: 15
    • View Profile
It's simple.

How you form the report?
by callback function?

no i didn't use callback i am just a beginner in limereport

 
Code: [Select]
report->loadFromFile(QDir::currentPath()+"/release/report/test2.lrxml");
    report->dataManager()->addModel("tablewidget",ui->tableWidget->model(),false);
    QStringList stringlist;
    stringlist.clear();
    for(int i=1;i<ui->tableWidget->rowCount();i++){
      stringlist<<QString::number(i);
    }
    qDebug()<<"stringlist="<<stringlist;
    QStringListModel* stringListModel = new QStringListModel();
    stringListModel->setStringList(stringlist);

     report->dataManager()->addModel("strlist",stringListModel,true);


     report->designReport();

in DataBand1 i am using QTableWidget as datasource
i got the strlist data successfully which it's value from 1 to 511
but when i use it it stays only 1 on every row
if i change databand1 datasource to strlist it became 1 ..... to 511
but QTableWidget became unchangable !!


« Last Edit: May 26, 2022, 01:33:42 pm by Proton Phoenix »

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
The real data changed in first variant?
But you can't got the string number?

Proton Phoenix

  • Newbie
  • *
  • Posts: 15
    • View Profile
The real data changed in first variant?
But you can't got the string number?

Yep the first variant changed every row to 511 of items .. because datasource is QTableWidget
but the second one didn't it only get the first index which is 1 and it keep repeating it ,because it's not the datasource of DataBand1
if i change the DataBind1 datasource to strlist it will get the second changed but the first one keep showing just the first index (product item) and keep repeating it
« Last Edit: May 26, 2022, 09:20:18 pm by Proton Phoenix »

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
can u send me your .lrxml file?

Proton Phoenix

  • Newbie
  • *
  • Posts: 15
    • View Profile
Thank you bro i did fix the problem by adding a column which contain the numbers then hiding it from the user in QTableWidget.