Results 1 to 2 of 2

Thread: QPrinter and two separate widgets to print on one page

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default QPrinter and two separate widgets to print on one page

    I have two separate widgets. I made a QPrintDialog and connected its paintRequested signal to my own slots of both widgets. The slots are here:

    Qt Code:
    1. void PicWidget::Print( QPrinter* printer )
    2. {
    3. cout << "PCW:P"<<endl;
    4. QPainter* painter = printer->paintEngine()->painter();
    5. if(!painter)
    6. painter = new QPainter(printer);
    7.  
    8. painter->begin(printer);
    9. painter->drawText(100,100, "PICW");
    10. painter->end();
    11. }
    12.  
    13. void BrWidget::Print( QPrinter* printer )
    14. {
    15. QPainter* painter = printer->paintEngine()->painter();
    16. if(!painter)
    17. painter = new QPainter(printer);
    18.  
    19.  
    20. painter->begin(printer);
    21. painter->drawText(100,200, "BRW");
    22. painter->end();
    23. }
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work: only one of the methods works properly. It also writes that two QPainters are working at once. How can i solve the problem?
    Last edited by wysota; 5th July 2009 at 10:05. Reason: Changed [qtclass] to [code]

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.