Results 1 to 2 of 2

Thread: Safe checking the QPrinter::PrintState after printing

  1. #1
    Join Date
    Jan 2008
    Posts
    7
    Thanks
    2

    Default Safe checking the QPrinter::PrintState after printing

    In my application I need to detect is paper out or not after each printing. Unfortunately my printer driver doesn't have API to do that, so I'm going to check the PrintState property like this:

    Qt Code:
    1. textDocument.print(&printer);
    2.  
    3. if (printer.printerState() == QPrinter::Error) someErrorHandler();
    To copy to clipboard, switch view to plain text mode 

    The problem is that print() method returns not waiting for the end of printing, so I need to use sleep() function like this:

    Qt Code:
    1. textDocument.print(&printer);
    2. mySleep(10);
    3. if (printer.printerState() == QPrinter::Error) someErrorHandler();
    To copy to clipboard, switch view to plain text mode 

    Is there any way to run print() method synchronously or detect that printer is out of paper defferently?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Safe checking the QPrinter::PrintState after printing

    Calling sleep in an event-based application isn't the best approach. You can use QTimer to check from time to time what happens with the printer.

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.