Change margin on QTextEdit print()
Hi!
I might be dumb, but can't figure out this... :(
So I have a nice QTextEdit... I want to print it, as in the big book:
Code:
printer.
setPageSize (QPrinter::A4); printer.
setFullPage (true);
if (dialog
->exec
() != QDialog::Accepted) return;
print (&printer);
I see it in the PDF file, it looks fine, but the margin is too big. Looks like the setFullPage(true) does nothing. I tried several stuff, a few to notice:
Change the document's margin and print that one:
http://trolltech.com/developer/knowl...17.5101025464/
Change printengine properity:
printer.printEngine()->setProperty(QPrintEngine::PPK_PaperRect, rect1);
If I try to print with the QPainter engine, it's fine and full page, just it's rather painful to work out with the painter.... and couldn't find a way to send the QTextEdit to painter.
Does anyone have any idea?
Re: Change margin on QTextEdit print()
Take http://doc.trolltech.com/4.1/qtextdocument.html from qtextedit
xdoc = edit->document();
and send this to dialog;
http://www.qt-apps.org/content/show....?content=62383
Code:
TextPrinter *textprinter_ = new TextPrinter(this);
textprinter_->setHeaderSize(0);
textprinter_->setLeftMargin(12);
textprinter_->setRightMargin(10);
textprinter_
->setHeaderText
(tr
("Foo date %1").
arg(QDateTime::currentDateTime().
toString()));
textprinter_->preview(xdoc, tr("Preview xx"));
Re: Change margin on QTextEdit print()
I just found out that the new version of Qt (4.4.0) contains some improvements regarding the margin handling:
"Made a number of improvements to printing in Qt 4.4, including support for setting custom page sizes and custom margins ... "
Textprinter is also fine...
Thank you for your help!