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. Create PDF from SQL data
Forum Updated to NodeBB v4.3 + New Features

Create PDF from SQL data

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k 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.
  • D Offline
    D Offline
    drich
    wrote on last edited by VRonin
    #1

    Hello I saw this on a forum this is what I want to do but in that forum no one could solve this. I already try and edit his code but I got the same result. Hope someone can solve this. Thank you! :)

    "Hi all,
    I'am writing an application that takes data from a sqlite database and show it thanks to a qtableview. I would like now to add a button export which export the data displayed in this view to a PDF file.
    Here is the slot I wrote:

    Qt Code: Switch view
    //Exporter la liste des utilisateurs

    void PageUser::genPdfUser()
    {
        QString filename="users.pdf";
        //Paramètres d'impression
        QPrinter printer(QPrinter::HighResolution);
        printer.setOutputFileName(filename);
        printer.setPaperSize(QPrinter::A4);
        printer.setOutputFormat(QPrinter::PdfFormat);
     
        QPainter painter(&printer);
        painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
        m_userView->render( &painter );
        painter.end();
    }
    

    To copy to clipboard, switch view to plain text mode

    It doesn't work because when I click the button, I have no reaction. Hindly help me to corect it.

    thanks"

    raven-worxR 1 Reply Last reply
    0
    • D drich

      Hello I saw this on a forum this is what I want to do but in that forum no one could solve this. I already try and edit his code but I got the same result. Hope someone can solve this. Thank you! :)

      "Hi all,
      I'am writing an application that takes data from a sqlite database and show it thanks to a qtableview. I would like now to add a button export which export the data displayed in this view to a PDF file.
      Here is the slot I wrote:

      Qt Code: Switch view
      //Exporter la liste des utilisateurs

      void PageUser::genPdfUser()
      {
          QString filename="users.pdf";
          //Paramètres d'impression
          QPrinter printer(QPrinter::HighResolution);
          printer.setOutputFileName(filename);
          printer.setPaperSize(QPrinter::A4);
          printer.setOutputFormat(QPrinter::PdfFormat);
       
          QPainter painter(&printer);
          painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
          m_userView->render( &painter );
          painter.end();
      }
      

      To copy to clipboard, switch view to plain text mode

      It doesn't work because when I click the button, I have no reaction. Hindly help me to corect it.

      thanks"

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @drich
      double post?!

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply
      0
      • artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #3

        Apart from double posting - where is painter.begin()?

        For more information please re-read.

        Kind Regards,
        Artur

        D 1 Reply Last reply
        0
        • artwawA artwaw

          Apart from double posting - where is painter.begin()?

          D Offline
          D Offline
          drich
          wrote on last edited by
          #4

          @artwaw I only saw the post on this site http://www.qtcentre.org/threads/45584-export-qtableview-in-PDF. this is what I also want to do, in the link/post to that site I dont get any solution for this problem. I also try to use the code and modify it but I end up to error or it doesnt show anything to the printpreview or to the pdf.

          1 Reply Last reply
          0
          • raven-worxR raven-worx

            @drich
            double post?!

            D Offline
            D Offline
            drich
            wrote on last edited by
            #5

            @raven-worx no, I just copy the post to this link http://www.qtcentre.org/threads/45584-export-qtableview-in-PDF, because we have the same problem but there is no right solution to the link. I also try to modify it but as of now it's not working.

            1 Reply Last reply
            0

            • Login

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