Results 1 to 9 of 9

Thread: help report generator program

  1. #1
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default help report generator program

    hi guys i'm very new to qt programing currently i use PyQt4 (Python+Qt)

    i want to ask a question about my new project "custom report generator"

    i tried many ways of implementing this program in QT but every method ends with stacked in missing features

    my real problem now is the reports pages can be more than 20000+ pages and i want the user to preview it before printing

    when using QPrintPreviewWidget it takes too long to draw the items usually "tables with text" and you can't print custom pages from QPrintPreviewWidget something like (from page 0 to 5)

    so i tried to paint in QGraphicsScene and implement my own QPrintPreviewWidget like
    then render the selected rectangles "pages" to printer directly

    i succeeded with that but drawing tables with text in QGraphicsScene take too long

    because i'm very very Newbie i draw the table columns,rows cell by cell of "QRectF" cause i want to align and format the text within the cells by sub-classing QGraphicsTextItem()
    and paint the text with custom font and bound it to specific rectangle then use QGraphicsScene.addItem() to add it

    this cause the QGraphicsScene to have lot's & lot's of items and objects
    when painting 70000 rows it takes 2GB of my ram then crashed

    so is there a way to draw my table with customized text (align and font)

    with better idea and doesn't have many objects to draw in QGraphicsScene()

    i know that my solution is newbie that's what i said before

    i can post sample if any one using PyQt4


    hope to find better idea

    thanx in advance

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: help report generator program

    Hi!

    I would create only one custom QGraphicsItem per page. In it's paintEvent you can draw everything on a QPainter just like you do when printing:

    Sorry - code is cpp; can you translate that?

    Qt Code:
    1. class Page : public QGraphicsItem {
    2. public:
    3. Page() {}
    4.  
    5. // You need to change that!
    6. QRectF boundingRect() const{ return QRectF(0, 0, 50, 50); }
    7.  
    8. void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget)
    9. {
    10. painter->drawRect(boundingRect());
    11. ....
    12. painter->setFont(..)
    13. painter->drawText(..)
    14. }
    15. };
    16.  
    17. Page* page = new Page();
    18. // set the content..
    19.  
    20. scene->addItem(page);
    To copy to clipboard, switch view to plain text mode 
    HIH

    Johannes

  3. #3
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: help report generator program

    thank you

    i will try your solution

    i think the translation of your code is sub-classing QGraphicsItem() and paint my table and text
    per page then add it to QGraphicsScene()

    i hope this helps

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 268 Times in 268 Posts
    Wiki edits
    20

    Default Re: help report generator program

    Quote Originally Posted by 0BLACK0 View Post
    my real problem now is the reports pages can be more than 20000+ pages and i want the user to preview it before printing
    I'm glad you call that the real problem.
    A report of more than 20000 pages? Really? That's not a report.
    And your users want to print this? Please tell why!
    What can any normal human being do with a printed 20000 page report? What can any sane human being do with 20000 pages at all?

  5. #5
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: help report generator program

    @tbscope: Excellent question. I didn't even really think about that!

    Maybe he is in politics :->

    Joh

  6. #6
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: help report generator program

    Just thought about it from another perspective:

    Why don't you print pages 1-5 onto a pdf Printer?

    Then you will use the same method as when you are really printing <-> less misprints!

    Joh

  7. #7
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: help report generator program

    Quote Originally Posted by tbscope View Post
    What can any normal human being do with a printed 20000 page report? What can any sane human being do with 20000 pages at all?
    my application generate invoices with lot's of customizations
    (table formatted with custom color & text formatted with colors and align )
    my company want that application to be very flexible cause we change our invoices look every 2 years at least
    that's why i called it report generator

  8. #8
    Join Date
    Sep 2010
    Posts
    5
    Qt products
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: help report generator program

    Quote Originally Posted by JohannesMunk View Post
    Why don't you print pages 1-5 onto a pdf Printer?
    Joh
    i can't print on any file for security purposes beside my company want the Audit Section to Review the invoices before printing it directly to the printer

    hope this helps

  9. #9
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: help report generator program

    Would an encrypted pdf on a ramdisk do? Maybe also for the final output? Bear in mind, the virtual water footprint of each A4 sheet is 10 liters! But we are getting off topic here.

    Let us know if you run into more Qt troubles!

  10. The following user says thank you to JohannesMunk for this useful post:

    0BLACK0 (21st September 2010)

Similar Threads

  1. Using QtScript Generator to generate my bindings
    By inpoculis789 in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2010, 22:59
  2. Replies: 0
    Last Post: 17th November 2009, 21:59
  3. JulyButton Class Generator
    By IGHOR in forum Qt Programming
    Replies: 7
    Last Post: 8th October 2008, 14:05
  4. Win32 UML generator from C++ .h files?
    By hickscorp in forum General Discussion
    Replies: 1
    Last Post: 13th May 2007, 19:05
  5. Random No Generator in C/C++
    By ankurjain in forum General Programming
    Replies: 1
    Last Post: 6th July 2006, 12:33

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
  •  
Qt is a trademark of The Qt Company.