Results 1 to 3 of 3

Thread: export qtableview in PDF

  1. #1
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default export qtableview in PDF

    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:
    1. //Exporter la liste des utilisateurs
    2. void PageUser::genPdfUser()
    3. {
    4. QString filename="users.pdf";
    5. //Paramètres d'impression
    6. QPrinter printer(QPrinter::HighResolution);
    7. printer.setOutputFileName(filename);
    8. printer.setPaperSize(QPrinter::A4);
    9. printer.setOutputFormat(QPrinter::PdfFormat);
    10.  
    11. QPainter painter(&printer);
    12. painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
    13. m_userView->render( &painter );
    14. painter.end();
    15. }
    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

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: export qtableview in PDF

    It doesn't work because when I click the button, I have no reaction.
    Is this method even called ?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: export qtableview in PDF

    What is the current working directory of the program? Probably not where you think it is (often the "Program Files\X" directory on Windows).
    Where is "user.pdf" going to be written? In the current working directory of the program.
    Can it be written there? Possibly not.
    Where are you looking for "user.pdf"? Possibly not in the current working directory of the program.

Similar Threads

  1. Replies: 16
    Last Post: 28th April 2020, 14:40
  2. Replies: 0
    Last Post: 29th September 2011, 08:32
  3. how to export dll with gui?
    By cutie.monkey in forum Qt Programming
    Replies: 5
    Last Post: 14th November 2009, 02:19
  4. How to export data from QTableView to Ms Excell
    By joseph in forum Qt Programming
    Replies: 2
    Last Post: 19th February 2009, 14:19
  5. Export SVG: Qwt Bug?
    By giusepped in forum Qwt
    Replies: 4
    Last Post: 19th December 2008, 10:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.