PDA

View Full Version : Wrapping while printing



veda
18th September 2007, 13:39
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,

Eg:
Appears in textEdit
-------------------------------------------------------------------------------------------------------
ABC.PVT.LTD .................................................. ............................................. 8/sep/2007
-------------------------------------------------------------------------------------------------------
After printing on the sheet of paper
-------------------------------------------------------------------------------------------------------
ABC.PVT.LTD
8/sep/2007
-------------------------------------------------------------------------------------------------------

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


const QTextDocument *doc = textEdit()->document();
(void)doc->documentLayout(); // make sure that there is a layout

QAbstractTextDocumentLayout *layout = doc->documentLayout(); //get the layout
QPaintDevice *pd = layout->paintDevice();
layout->setPaintDevice(paint.device());

QTextFrameFormat fmt = doc->rootFrame()->frameFormat();
fmt.setMargin(margin.x());
doc->rootFrame()->setFrameFormat(fmt);

textEdit()->document()->setPageSize(fRect.size());
textEdit()->document()->setTextWidth(fRect.width());
textEdit()->document()->setDefaultStyleSheet(textEdit()->styleSheet());

textEdit()->document()->setDefaultFont(fFont);
paint.setFont(fFont);
//clipping the content of the QTextDocument
// QRect rec = QRect(margin.x(),(fRect.topLeft().y()),fRect.width (),fRect.height());
// textEdit()->document()->drawContents(&paint,rec );


textEdit()->document()->drawContents( &paint );
layout->setPaintDevice(pd);
paint.restore();

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

wysota
18th September 2007, 13:55
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.

veda
18th September 2007, 14:19
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????

wysota
18th September 2007, 15:37
No. Take a look at "Printing with Qt" page in the docs.
http://doc.trolltech.com/latest/printing.html