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
-------------------------------------------------------------------------------------------------------
Eg:
Appears in textEdit
-------------------------------------------------------------------------------------------------------
ABC.PVT.LTD ............................................................................................... 8/sep/2007
-------------------------------------------------------------------------------------------------------
After printing on the sheet of paper
-------------------------------------------------------------------------------------------------------
ABC.PVT.LTD
8/sep/2007
-------------------------------------------------------------------------------------------------------
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
(void)doc->documentLayout(); // make sure that there is a layout
layout->setPaintDevice(paint.device());
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();
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();
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
Bookmarks