Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtRpt report from Databse
QtWS25 Last Chance

QtRpt report from Databse

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt creatordatabaseqtrpt
13 Posts 7 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neel 0
    wrote on 20 Feb 2018, 11:05 last edited by
    #1

    Hello ,
    I am using QtRpt for creating reports. I can generate report from tablewidget. When I trying to get data from database then I facing problem . Anyone can help in this?

    Below is My Code.

    void MainWindow::on_btnGenrateReport_clicked()
    {
        QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db");
        if(!db.open())
        {
            qDebug()<<"Database not Open"<<endl;
        }
        else
        {
            QSqlQuery  qry;
            qry.prepare("select * from vs_channel");
            if(!qry.exec())
            {
                qDebug()<<"Error in Query"<<endl;
            }
            else
            {
                QtRPT *report = new QtRPT(this);
                while(qry.next())
                {
    
                qDebug()<<qry.value(12).toString()<<endl;
                qDebug()<<qry.value(1).toString()<<endl;
                qDebug()<<qry.value(6).toString()<<endl;
    
                    report->loadReport(":/chreport.xml");
                    connect(report,&QtRPT::setValue,[&](const int recNo,
                            const QString paramName, QVariant &paramValue, const int reportPage)
                    {
                        (void) reportPage;
                        if(paramName=="channel_id")
                        {
                            paramValue=(recNo,qry.value(12).toString());
                            qDebug()<<paramValue<<endl;
                        }
                        if(paramName=="channel_tag")
                        {
                            paramValue=(recNo,qry.value(1).toString());
                            qDebug()<<paramValue<<endl;
                        }
                        if(paramName=="unit")
                        {
                            paramValue=(recNo,qry.value(6).toString());
                            qDebug()<<paramValue<<endl;
                        }
    
    
                    });
    
                }report->printExec();
            }
    
        }
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Feb 2018, 13:19 last edited by
      #2

      Hi,

      QtRPT is not an official Qt module, so you should try contacting its author or use their forum.

      In any case, you should also explain exactly what you are expecting and what you are getting.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 16 Apr 2021, 13:15
      2
      • N Offline
        N Offline
        Neel 0
        wrote on 27 Feb 2018, 12:15 last edited by
        #3

        Hello,
        This problem is solved.

        here is the right code.

        void MainWindow::on_btnGenrateReport_clicked()
        {
            QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
            db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db");
            if(!db.open())
            {
                qDebug()<<"Database not Open"<<endl;
            }
            else
            {
                QSqlQuery  qry;
                qry.prepare("select * from vs_channel");
                if(!qry.exec())
                {
                    qDebug()<<"Error in Query"<<endl;
                }
                else
                {
                    QtRPT *report = new QtRPT(this);
                    while(qry.next())
                    {
                       p = new pojo();
                       p->setChannel_id(qry.value(12).toString());
                       p->setChannel_tag(qry.value(1).toString());
                       p->setUnit(qry.value(6).toString());
        
                        plist.push_back(p);
                   }
        
                    report->loadReport(":/chreport.xml");
                    report->recordCount.append(plist.count());
                   
        
                   connect(report,&QtRPT::setValue,[&](const int recNo,
                                const QString paramName, QVariant &paramValue, const int reportPage)
                    {
                        (void) reportPage;
                        if(paramName=="channel_id")
                        {
                            paramValue=plist[recNo]->getChannel_id();
        
                        }
                        if(paramName=="channel_tag")
                        {
                            paramValue=plist[recNo]->getChannel_tag();
                        }
                        if(paramName=="unit")
                        {
                            paramValue=plist[recNo]->getUnit();
                        }
        
                    });
        
                  
        
                    report->printExec();
                }
        
            }
        }
        

        I had created one pojo class for getter setter method.

        M K 2 Replies Last reply 24 Mar 2018, 06:54
        1
        • N Neel 0
          27 Feb 2018, 12:15

          Hello,
          This problem is solved.

          here is the right code.

          void MainWindow::on_btnGenrateReport_clicked()
          {
              QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
              db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db");
              if(!db.open())
              {
                  qDebug()<<"Database not Open"<<endl;
              }
              else
              {
                  QSqlQuery  qry;
                  qry.prepare("select * from vs_channel");
                  if(!qry.exec())
                  {
                      qDebug()<<"Error in Query"<<endl;
                  }
                  else
                  {
                      QtRPT *report = new QtRPT(this);
                      while(qry.next())
                      {
                         p = new pojo();
                         p->setChannel_id(qry.value(12).toString());
                         p->setChannel_tag(qry.value(1).toString());
                         p->setUnit(qry.value(6).toString());
          
                          plist.push_back(p);
                     }
          
                      report->loadReport(":/chreport.xml");
                      report->recordCount.append(plist.count());
                     
          
                     connect(report,&QtRPT::setValue,[&](const int recNo,
                                  const QString paramName, QVariant &paramValue, const int reportPage)
                      {
                          (void) reportPage;
                          if(paramName=="channel_id")
                          {
                              paramValue=plist[recNo]->getChannel_id();
          
                          }
                          if(paramName=="channel_tag")
                          {
                              paramValue=plist[recNo]->getChannel_tag();
                          }
                          if(paramName=="unit")
                          {
                              paramValue=plist[recNo]->getUnit();
                          }
          
                      });
          
                    
          
                      report->printExec();
                  }
          
              }
          }
          

          I had created one pojo class for getter setter method.

          M Offline
          M Offline
          Mahesh Arrajella
          wrote on 24 Mar 2018, 06:54 last edited by
          #4

          @Neel-0 where can i get the full source code

          A 1 Reply Last reply 4 Jan 2019, 13:00
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 24 Mar 2018, 22:23 last edited by
            #5

            Hi,

            Using the answer to a simple query.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • M Mahesh Arrajella
              24 Mar 2018, 06:54

              @Neel-0 where can i get the full source code

              A Offline
              A Offline
              aliks-os
              wrote on 4 Jan 2019, 13:00 last edited by
              #6

              @Mahesh-Arrajella The official web site of QtRPT project here http://www.qtrpt.tk

              aha_1980A 1 Reply Last reply 4 Jan 2019, 16:07
              0
              • A aliks-os
                4 Jan 2019, 13:00

                @Mahesh-Arrajella The official web site of QtRPT project here http://www.qtrpt.tk

                aha_1980A Offline
                aha_1980A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on 4 Jan 2019, 16:07 last edited by
                #7

                @aliks-os

                http://www.qtrpt.tk

                I cannot connect to this site...

                Qt has to stay free or it will die.

                A 1 Reply Last reply 23 Jun 2021, 06:37
                0
                • N Neel 0
                  27 Feb 2018, 12:15

                  Hello,
                  This problem is solved.

                  here is the right code.

                  void MainWindow::on_btnGenrateReport_clicked()
                  {
                      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
                      db.setDatabaseName("/home/gtek/Work/validscan_proj/validscan_db");
                      if(!db.open())
                      {
                          qDebug()<<"Database not Open"<<endl;
                      }
                      else
                      {
                          QSqlQuery  qry;
                          qry.prepare("select * from vs_channel");
                          if(!qry.exec())
                          {
                              qDebug()<<"Error in Query"<<endl;
                          }
                          else
                          {
                              QtRPT *report = new QtRPT(this);
                              while(qry.next())
                              {
                                 p = new pojo();
                                 p->setChannel_id(qry.value(12).toString());
                                 p->setChannel_tag(qry.value(1).toString());
                                 p->setUnit(qry.value(6).toString());
                  
                                  plist.push_back(p);
                             }
                  
                              report->loadReport(":/chreport.xml");
                              report->recordCount.append(plist.count());
                             
                  
                             connect(report,&QtRPT::setValue,[&](const int recNo,
                                          const QString paramName, QVariant &paramValue, const int reportPage)
                              {
                                  (void) reportPage;
                                  if(paramName=="channel_id")
                                  {
                                      paramValue=plist[recNo]->getChannel_id();
                  
                                  }
                                  if(paramName=="channel_tag")
                                  {
                                      paramValue=plist[recNo]->getChannel_tag();
                                  }
                                  if(paramName=="unit")
                                  {
                                      paramValue=plist[recNo]->getUnit();
                                  }
                  
                              });
                  
                            
                  
                              report->printExec();
                          }
                  
                      }
                  }
                  

                  I had created one pojo class for getter setter method.

                  K Offline
                  K Offline
                  Ketan__Patel__0011
                  wrote on 16 Mar 2020, 11:20 last edited by
                  #8

                  @Neel-0 Hey Bro Can You Share This Code ?

                  I am working on Report from the last three Days

                  help Me Brother

                  1 Reply Last reply
                  0
                  • S SGaist
                    20 Feb 2018, 13:19

                    Hi,

                    QtRPT is not an official Qt module, so you should try contacting its author or use their forum.

                    In any case, you should also explain exactly what you are expecting and what you are getting.

                    A Offline
                    A Offline
                    ali-aydin
                    wrote on 16 Apr 2021, 13:15 last edited by
                    #9

                    @SGaist
                    so what is the official Qt module for reporting?
                    reporting from data in SQL.

                    S 1 Reply Last reply 16 Apr 2021, 18:55
                    0
                    • A ali-aydin
                      16 Apr 2021, 13:15

                      @SGaist
                      so what is the official Qt module for reporting?
                      reporting from data in SQL.

                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 16 Apr 2021, 18:55 last edited by
                      #10

                      @ali-aydin there are none officially provided by the Qt Company. QtRpt is one well known. AFAIK, they have moved their website.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply 19 Apr 2021, 16:45
                      0
                      • S SGaist
                        16 Apr 2021, 18:55

                        @ali-aydin there are none officially provided by the Qt Company. QtRpt is one well known. AFAIK, they have moved their website.

                        A Offline
                        A Offline
                        ali-aydin
                        wrote on 19 Apr 2021, 16:45 last edited by
                        #11

                        @SGaist
                        when I using the QtRpt it does not work
                        I read that's manually but something is wrong and i can't find that
                        Errot like this :
                        sub-QtRptDesigner-qmake-all] Error2

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 19 Apr 2021, 18:13 last edited by
                          #12

                          That's not enough information. Please open your own thread about that issue and provide complete information like Qt version used, platform, QtRpt version and full error output.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          A 1 Reply Last reply 20 Apr 2021, 17:42
                          0
                          • aha_1980A aha_1980
                            4 Jan 2019, 16:07

                            @aliks-os

                            http://www.qtrpt.tk

                            I cannot connect to this site...

                            A Offline
                            A Offline
                            aliks-os
                            wrote on 23 Jun 2021, 06:37 last edited by
                            #13

                            @aha_1980 Unfortunately the link http://www.qtrpt.tk is no more working.
                            To get official source of the project please use
                            https://sourceforge.net/p/qtrpt/discussion/general/

                            1 Reply Last reply
                            2

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved