Results 1 to 6 of 6

Thread: Printing issue

  1. #1
    Join Date
    May 2009
    Location
    Secunderabad, India
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Printing issue

    I am Interested in printing some text on a Pre-Printed Document.
    how am i supposed to align the text & print it on the Document ?

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Printing issue

    take a look at QTextDocument and QTextEdit (which uses QTextDocument).
    Another thing would be to use QGraphicsView where your QGraphicsScene would have the existing content as background and then you can use QGraphicsTextItem to position some additional text, and at the end you can render scene to the printer.
    Hope that I understood you right :]
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    May 2009
    Location
    Secunderabad, India
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Printing issue

    The "Pre-Printed Document" am i referring to is a Pre-Printed Paper , ie some printing has been done on a paper sheet , now i need to print some additional text at some desired locations on the paper.

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Printing issue

    So you can take a look at this example: http://doc.qtsoftware.com/4.5/demos-textedit.html and you can find it in Qt Examples & Demos -> Demonstrations -> Text Edit.

    As for the solution with QGraphicsView you can make something like page preview with QGraphicsTextItems in it, and make some of these items be editable and maybe movable
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Printing issue

    Use a typewriter

  6. #6
    Join Date
    May 2009
    Location
    Secunderabad, India
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: Printing issue

    @Ini : No need of Typewriter !

    i found a solution.i used QPainter::drawText() to align the text at a desired location on the Pre-Printed form (paper)

    Here is the Code :

    QPrinter printer(QPrinter::HighResolution);
    printer.setPaperSize(QPrinter::A4);
    printer.setOrientation(QPrinter::Portrait);
    printer.setFullPage(true);
    QPainter painter(&printer);
    QPointF pt;
    pt.setX(20 * (printer.width()/printer.widthMM()));
    pt.setY(20 * (printer.height()/printer.heightMM())) ;

    painter.drawText ( pt, "prints at 20mm X 20mm");

    ----

    Thanks all , for Replying .

Similar Threads

  1. Printing txt file vs Printing pdf file
    By rmagro in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2012, 15:45
  2. Replies: 8
    Last Post: 27th April 2009, 19:19
  3. Qt4 poor printing performance
    By seneca in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2009, 14:23
  4. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  5. Replies: 0
    Last Post: 28th June 2006, 20:49

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.