PDA

View Full Version : Safe checking the QPrinter::PrintState after printing



mSergey
18th January 2008, 12:04
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:


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:


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!

jacek
18th January 2008, 16:37
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.