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:
Code:
textDocument.print(&printer);
if (printer.
printerState() == QPrinter::Error) someErrorHandler
();
The problem is that print() method returns not waiting for the end of printing, so I need to use sleep() function like this:
Code:
textDocument.print(&printer);
mySleep(10);
if (printer.
printerState() == QPrinter::Error) someErrorHandler
();
Is there any way to run print() method synchronously or detect that printer is out of paper defferently?
Thanks!
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.