Results 1 to 4 of 4

Thread: Wrapping while printing

  1. #1
    Join Date
    Apr 2007
    Location
    Bangalore,India
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Wrapping while printing

    Hello All,

    I want to print the content of My textEdit exactly on to a sheet of paper.
    I am printing the content of the QTextEdit, After I print, the content of textEdit
    is wrapped,
    Qt Code:
    1. Eg:
    2. Appears in textEdit
    3. -------------------------------------------------------------------------------------------------------
    4. ABC.PVT.LTD ............................................................................................... 8/sep/2007
    5. -------------------------------------------------------------------------------------------------------
    6. After printing on the sheet of paper
    7. -------------------------------------------------------------------------------------------------------
    8. ABC.PVT.LTD
    9. 8/sep/2007
    10. -------------------------------------------------------------------------------------------------------
    To copy to clipboard, switch view to plain text mode 
    The date that is there in the line is getting wrapped to the next line.

    How do I solve this???
    I think I need to set some scaling factor,But How???
    Below is My code

    Qt Code:
    1. const QTextDocument *doc = textEdit()->document();
    2. (void)doc->documentLayout(); // make sure that there is a layout
    3.  
    4. QAbstractTextDocumentLayout *layout = doc->documentLayout(); //get the layout
    5. QPaintDevice *pd = layout->paintDevice();
    6. layout->setPaintDevice(paint.device());
    7.  
    8. QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
    9. fmt.setMargin(margin.x());
    10. doc->rootFrame()->setFrameFormat(fmt);
    11.  
    12. textEdit()->document()->setPageSize(fRect.size());
    13. textEdit()->document()->setTextWidth(fRect.width());
    14. textEdit()->document()->setDefaultStyleSheet(textEdit()->styleSheet());
    15.  
    16. textEdit()->document()->setDefaultFont(fFont);
    17. paint.setFont(fFont);
    18. //clipping the content of the QTextDocument
    19. // QRect rec = QRect(margin.x(),(fRect.topLeft().y()),fRect.width(),fRect.height());
    20. // textEdit()->document()->drawContents(&paint,rec );
    21.  
    22.  
    23. textEdit()->document()->drawContents( &paint );
    24. layout->setPaintDevice(pd);
    25. paint.restore();
    To copy to clipboard, switch view to plain text mode 

    And I need to print the content in the end of the page something like footer content.
    How do I reposition the y-axis????

    Thanks
    Last edited by veda; 18th September 2007 at 14:13.
    Veda

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Wrapping while printing

    Did you use white spaces to move the date to the right? You should have used some rich text tags, like tables or css text alignment. The width of your printing area is different than the width of the text edit, thus the difference you get. You might try scaling the printer painter first, but I doubt you'll be happy with the result.

  3. #3
    Join Date
    Apr 2007
    Location
    Bangalore,India
    Posts
    25
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Wrapping while printing

    Quote Originally Posted by wysota View Post
    Did you use white spaces to move the date to the right? You should have used some rich text tags, like tables or css text alignment. The width of your printing area is different than the width of the text edit, thus the difference you get. You might try scaling the printer painter first, but I doubt you'll be happy with the result.
    Yes I have used spaces....

    Are you speaking about QTextTableFormat Class,

    Can you brief me about it... How do I use it...

    And How do I reposition the y-axis????
    Veda

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Wrapping while printing

    No. Take a look at "Printing with Qt" page in the docs.
    http://doc.trolltech.com/latest/printing.html

Similar Threads

  1. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  2. Printing a Qstring
    By harakiri in forum Newbie
    Replies: 6
    Last Post: 24th June 2007, 12:52
  3. Word wrapping in a QTableWidget cell
    By jcooperddtd in forum Qt Programming
    Replies: 3
    Last Post: 1st May 2007, 03:57
  4. Re: Printing in Qt
    By Jimmy2775 in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 23:00
  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.