Results 1 to 3 of 3

Thread: Qt4 : QPainter::setRedirected doesn't work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    Bangalore
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Qt4 : QPainter::setRedirected doesn't work

    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.

    Qt Code:
    1. void print()
    2. {
    3. QPrinter printer;
    4. printer.setOutputFormat(QPrinter::PdfFormat);
    5. printer.setOutputFileName("C:/sample.pdf");
    6. printer.setPageSize(QPrinter::A4);
    7.  
    8. QPainter::setRedirected(widget, &printer);
    9. QPaintEvent pe(this->rect());
    10. qApp->sendEvent(this, &pe);
    11. QPainter::restoreRedirected(widget);
    12. widget->repaint();
    13. }
    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
    Last edited by marcel; 20th June 2008 at 18:56. Reason: missing [code] tags

Similar Threads

  1. Copy / Paste doesn't work with LineEdit
    By ia32 in forum Qt Tools
    Replies: 2
    Last Post: 5th May 2008, 21:44
  2. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  3. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20
  4. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 12:02

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.