You should do some error checking.
Use these steps:
1. Find the state of printer just before printing.
Qt Code:
  1. QPrinter::printerState()
To copy to clipboard, switch view to plain text mode 
2. Check for general connectivity of printer with your machine. Try to print a test page from your machine.
3. Use:
Qt Code:
  1. QPrinter::isValid ()
To copy to clipboard, switch view to plain text mode