Hi,
I am trying to divert the paint operations of a widget to the printer.
But it doesn't seem to work for me.
following is the code.
void print()
{
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("C:/sample.pdf");
QPainter::setRedirected(widget,
&printer
);
qApp->sendEvent(this, &pe);
widget->repaint();
}
void print()
{
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName("C:/sample.pdf");
printer.setPageSize(QPrinter::A4);
QPainter::setRedirected(widget, &printer);
QPaintEvent pe(this->rect());
qApp->sendEvent(this, &pe);
QPainter::restoreRedirected(widget);
widget->repaint();
}
To copy to clipboard, switch view to plain text mode
Initially, i used widget->repaint() instead of sendevent(). But didnt work either.
If i query redirected() function on the widget before restoring the redirection , it is correctly showing the redirected device as printer. I wonder still why this code doesn't work!
Am i doing any mistake here?
Pls help
-
Ankitha
Bookmarks