PDA

View Full Version : Printing from a textEdit



Nefastious
19th October 2009, 19:38
Hi guys,

I was wondering how to print from a QTextEdit. Please don't send me any links to trolltech documentation. I have read it and I have found it to be confusing (at least to me).

Any code samples would be appreciated.

Thanks in advance,

Nefastious :P

Lykurg
19th October 2009, 20:04
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("print.ps");
QPainter painter;
painter.begin(&printer);
painter.drawText(painter.pageRect(), YourQStringHere);
painter.end();


Please don't send me any links to trolltech documentation. I have read it and I have found it to be confusing (at least to me).
Then you should probably learn C++ first since the documentations is the best out there for a c++ framework. And if you don't understand that reference you lacking to much object orientated knowledge to combine the documentations of QPrinter and QPainter...

briang
21st October 2009, 06:29
under ui->setupUi(this);
printer = new QPrinter;

then
textEdit->print(printer)