Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Report Engine for Qt?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Report Engine for Qt?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 6 Posters 3.8k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    maximus
    wrote on 30 Jan 2015, 17:38 last edited by
    #1

    Hi guys,

    I have a Qt interface that I would like to be able to print to a report (pdf file)
    "Here is the interface":https://www.dropbox.com/s/2hdu00g8rrdtu6k/qwtPlotReport.png?dl=0

    For now I use QwtPlotRenderer that does a great job as printing the graph to a PDF.
    I would also like to incorporate some other data on top of the graph (Name, Description, etc.)
    This is a basic report with no request to the database, just some formatting of what I have in the Qt interface and printing it to a PDF.

    Is there some tools integrated in Qt for that? I have looked at third party option (QtRPT, NcReport) but they don't really fit my needs, I would rather code a routine that print my own PDF.

    Thanks!

    Current code :
    @void WorkoutCreator::exportWorkoutToPdf() {

    /// TODO: Add Title, remove background image, increase margins
    ui->widget_plot_report->setTitle(workout.getName().toUpper() + "-" + workout.getPlan());
    ui->widget_plot_report->setContentsMargins(20,20,20,20);
    ui->widget_plot_report->setAxisTitle(2, tr("Time"));
    
    
    
    QString fileNameToShow = ui->widget_plot_report->getSavePathExport() + QDir::separator() +  workout.getName();
    QString fileName = QFileDialog::getSaveFileName(this, tr("Export Workout"), fileNameToShow, tr("PDF Documents(*.pdf)"));
    if (fileName.isEmpty())
        return;
    
    QwtPlotRenderer renderer;
    renderer.exportToFile(ui->widget_plot_report, fileName);
    
    
    //Save path for future uses
    QFileInfo fileInfo(fileName);
    ui->widget_plot_report->savePathExport(fileInfo.absolutePath());
    
    showStatusBarMessage(tr("Saved to: ") + fileName, 7000);
    

    }@


    Free Indoor Cycling Software - https://maximumtrainer.com

    T A 2 Replies Last reply 4 Sept 2015, 07:36
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 31 Jan 2015, 00:56 last edited by
      #2

      Hi,

      Does the "Qt Print Support":http://doc.qt.io/qt-5/qtprintsupport-index.html module fit your needs?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 2 Feb 2015, 07:33 last edited by
        #3

        You can print to PDF just fine, and that includes printing Qwt plots. However, you should be aware that directly printing widgets doesn't result in pretty reports. The average screen has a dpi resolution that is far lower than a normal DPI for a PDF, let alone for a printer. There can be an order of magnitude difference.

        I wrote a report engine for our company in order to work with all that. It is based on Qt's PDF engine and it also prints out Qwt graphs, but it is not trivial to make everything look nice if you start from scratch.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on 2 Feb 2015, 13:20 last edited by
          #4

          Thanks for the response!

          Custom report using QPainter looks to be the solution I'll be trying. I won't paint the other widgets directly to the report (except the Qwt plot that already looks fine). I'll format the rest differently using QPainter.

          Have a good day,
          Max


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • M maximus
            30 Jan 2015, 17:38

            Hi guys,

            I have a Qt interface that I would like to be able to print to a report (pdf file)
            "Here is the interface":https://www.dropbox.com/s/2hdu00g8rrdtu6k/qwtPlotReport.png?dl=0

            For now I use QwtPlotRenderer that does a great job as printing the graph to a PDF.
            I would also like to incorporate some other data on top of the graph (Name, Description, etc.)
            This is a basic report with no request to the database, just some formatting of what I have in the Qt interface and printing it to a PDF.

            Is there some tools integrated in Qt for that? I have looked at third party option (QtRPT, NcReport) but they don't really fit my needs, I would rather code a routine that print my own PDF.

            Thanks!

            Current code :
            @void WorkoutCreator::exportWorkoutToPdf() {

            /// TODO: Add Title, remove background image, increase margins
            ui->widget_plot_report->setTitle(workout.getName().toUpper() + "-" + workout.getPlan());
            ui->widget_plot_report->setContentsMargins(20,20,20,20);
            ui->widget_plot_report->setAxisTitle(2, tr("Time"));
            
            
            
            QString fileNameToShow = ui->widget_plot_report->getSavePathExport() + QDir::separator() +  workout.getName();
            QString fileName = QFileDialog::getSaveFileName(this, tr("Export Workout"), fileNameToShow, tr("PDF Documents(*.pdf)"));
            if (fileName.isEmpty())
                return;
            
            QwtPlotRenderer renderer;
            renderer.exportToFile(ui->widget_plot_report, fileName);
            
            
            //Save path for future uses
            QFileInfo fileInfo(fileName);
            ui->widget_plot_report->savePathExport(fileInfo.absolutePath());
            
            showStatusBarMessage(tr("Saved to: ") + fileName, 7000);
            

            }@

            T Offline
            T Offline
            TEHb
            wrote on 4 Sept 2015, 07:36 last edited by
            #5

            @maximus, maybe try limereport.sourceforge.net ?

            1 Reply Last reply
            0
            • M maximus
              30 Jan 2015, 17:38

              Hi guys,

              I have a Qt interface that I would like to be able to print to a report (pdf file)
              "Here is the interface":https://www.dropbox.com/s/2hdu00g8rrdtu6k/qwtPlotReport.png?dl=0

              For now I use QwtPlotRenderer that does a great job as printing the graph to a PDF.
              I would also like to incorporate some other data on top of the graph (Name, Description, etc.)
              This is a basic report with no request to the database, just some formatting of what I have in the Qt interface and printing it to a PDF.

              Is there some tools integrated in Qt for that? I have looked at third party option (QtRPT, NcReport) but they don't really fit my needs, I would rather code a routine that print my own PDF.

              Thanks!

              Current code :
              @void WorkoutCreator::exportWorkoutToPdf() {

              /// TODO: Add Title, remove background image, increase margins
              ui->widget_plot_report->setTitle(workout.getName().toUpper() + "-" + workout.getPlan());
              ui->widget_plot_report->setContentsMargins(20,20,20,20);
              ui->widget_plot_report->setAxisTitle(2, tr("Time"));
              
              
              
              QString fileNameToShow = ui->widget_plot_report->getSavePathExport() + QDir::separator() +  workout.getName();
              QString fileName = QFileDialog::getSaveFileName(this, tr("Export Workout"), fileNameToShow, tr("PDF Documents(*.pdf)"));
              if (fileName.isEmpty())
                  return;
              
              QwtPlotRenderer renderer;
              renderer.exportToFile(ui->widget_plot_report, fileName);
              
              
              //Save path for future uses
              QFileInfo fileInfo(fileName);
              ui->widget_plot_report->savePathExport(fileInfo.absolutePath());
              
              showStatusBarMessage(tr("Saved to: ") + fileName, 7000);
              

              }@

              A Offline
              A Offline
              aliks-os
              wrote on 9 Oct 2015, 08:05 last edited by
              #6

              @maximus
              From QtRPT you may build your own pdf file

              1 Reply Last reply
              0
              • AlexA Offline
                AlexA Offline
                Alex
                wrote on 3 Oct 2016, 07:10 last edited by
                #7

                Old topic, but for someone who will be looking for a reporting tool like FastReport or Crystal Reports, consider CuteReport.
                It has both GPL/LGPL and proprietary Enterprise version and supports graphs with export to PDF:
                [URL="https://cute-report.com/"]https://cute-report.com/[/URL]
                [URL="https://sourceforge.net/projects/qreport/?"]https://sourceforge.net/projects/qreport/?[/URL]

                https://cute-report.com

                1 Reply Last reply
                -1

                • Login

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