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

Author Topic: Qtablewidget  (Read 3471 times)

Fery

  • Newbie
  • *
  • Posts: 2
    • View Profile
Qtablewidget
« on: August 13, 2017, 07:55:33 am »
Hi
I have a qtablewidget and I want to make report from its data, please tell me how can I do ?

Thank you

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Qtablewidget
« Reply #1 on: August 15, 2017, 12:01:26 am »
Hi

It's easy to do. Just add qtablewidget.model() to the limereport.
Code: [Select]
report->dataManager()->addModel("TreeWidget", ui->tableWidget->model(), false);
   

Fery

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Qtablewidget
« Reply #2 on: August 16, 2017, 07:49:20 am »
Hi
Sorry but I'm newbi.
Below is my code that fill qtablewidget.
Code: [Select]
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();

And this a code when click a push button to show a report.
Code: [Select]
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();

And this my my report

https://ufile.io/fy63b


My report open but it shows nothing.

Thank you for your guide

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Qtablewidget
« Reply #3 on: August 16, 2017, 10:24:39 pm »