Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

connexion QT and NCReport



  • Hello everyone ,
    I am in the process of connecting Qt and NCReport. but I have some error on my code. please

    *----------------------------------------- .pro
    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets #--printsupport
    #----------------------
    TARGET = Reportdms
    TEMPLATE = app
    #---------------------- .pro
    CONFIG += c++11

    You can make your code fail to compile if it uses deprecated APIs.

    In order to do so, uncomment the following line.

    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

    SOURCES +=
    main.cpp
    widget.cpp

    HEADERS +=
    widget.h

    FORMS +=
    widget.ui

    QMAKE_CXXFLAGS += -std =gnu++14

    Default rules for deployment.

    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target

    include($$PWD/QtRptProject/QtRPT/QtRPT.pri)

    *------------------------------ .h
    #ifndef WIDGET_H
    #define WIDGET_H

    #include <QWidget>

    QT_BEGIN_NAMESPACE
    namespace Ui { class Widget; }
    QT_END_NAMESPACE

    class Widget : public QWidget
    {
    Q_OBJECT

    public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    private slots:
    void on_agregarButton_clicked();

    void on_eliminarButton_clicked();
    
    void on_imprimirButton_clicked();
    

    private:
    enum {
    ID,
    NOM,
    AGE,
    SALAIRE
    };
    Ui::Widget *ui;
    };
    #endif // WIDGET_H
    //----------------------------- .cpp
    #include "widget.h"
    #include "ui_widget.h"
    #include<QtRptProject/QtRPT/qtrpt.h>
    //#include<QtRPT>
    Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    {
    ui->setupUi(this);
    const QStringList titles {"ID", "NOM","AGE","SALAIRE"};
    // QString nombre = ui->nombreLineEdit->text();
    ui->tableWidget->setColumnCount(titles.size());
    ui->tableWidget->setHorizontalHeaderLabels(titles);
    // ui->tableWidget->setColumnCount(4);
    ui->idSpinBox->setMinimum(0);
    ui->idSpinBox->setMaximum(INT_MAX);
    ui->edadSpinBox->setMinimum(0);
    ui->edadSpinBox->setMaximum(INT_MAX);
    ui->salarioDoubleSpinBox->setMinimum(0.0);
    ui->salarioDoubleSpinBox->setMaximum(99999999.0);
    }

    Widget::~Widget()
    {
    delete ui;
    }

    void Widget::on_agregarButton_clicked()
    {
    const QString id = QString::number(ui->idSpinBox->value());
    const QString nombre = ui->nombreLineEdit->text();
    const QString age = QString::number(ui->edadSpinBox->value());
    const QString salario = QString::number(ui->salarioDoubleSpinBox->value());
    const int rowCount = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(rowCount);
    ui->tableWidget->setItem(rowCount, ID, new QTableWidgetItem(id));
    ui->tableWidget->setItem(rowCount, NOM, new QTableWidgetItem(nombre));
    ui->tableWidget->setItem(rowCount, AGE, new QTableWidgetItem(age));
    ui->tableWidget->setItem(rowCount, SALAIRE, new QTableWidgetItem(salario));
    ui->idSpinBox->clear();
    ui->nombreLineEdit->clear();
    ui->edadSpinBox->clear();
    ui->salarioDoubleSpinBox->clear();
    ui->idSpinBox->setFocus();
    }

    void Widget::on_eliminarButton_clicked()
    {
    ui->tableWidget->removeRow(ui->tableWidget->currentRow());
    }

    void Widget::on_imprimirButton_clicked()
    {
    QtRPT report = new QtRPT(this);
    report->recordCount.append(ui->tableWidget->rowCount());
    connect(report, &QtRPT::setValue, [&](const int recNo,
    const QString paramName, QVariant &paramValue,
    const int reportPage){
    (void) reportPage;
    /
    if(paramName=="id"){
    paramValue =ui->tableWidget->item(recNo,ID);
    }
    if(paramName=="nombre"){
    paramValue = ui->tableWidget->item(recNo,NOM);
    }
    if(paramName=="age"){
    paramValue = ui->tableWidget->item(recNo,AGE);
    }
    if(paramName=="salario"){
    paramValue = ui->tableWidget->item(recNo,SALAIRE);
    }*/

    });
    

    }
    //----------------------------------------------- main.cpp
    #include "widget.h"

    #include <QApplication>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    a.setStyle("fusion");
    Widget w;
    w.show();
    return a.exec();
    }
    here are the results after compilation:
    Unknown module(s) in QT :script
    [Makefile:189:Makefile] Error 3


  • Lifetime Qt Champion



  • @jsulm I added QT += script in .pro but it still doesn't work.
    Thank you for your answer
    here are the results after compilation:
    Unknown module(s) in QT :script
    [Makefile:189:Makefile] Error 3


  • Lifetime Qt Champion

    Hi,

    You have to explicitly install it. That module was deprecated a long time ago.


Log in to reply