qt - Error Handling in QPrinter -


when printing pdf qtextdocument , qprinter there way of detecting errors (e.g. not being able write pdf file)? i'm using following code:

qtextdocument document; qprinter printer( qprinter::highresolution ); printer.setoutputformat( qprinter::pdfformat ); printer.setoutputfilename( filename ); document.print( &printer ); 

in docs you'll find qprinter::printerstate. can do:

if (printer.printerstate() == qprinter::error)     // error handling 

i admit that's not lot work with, there 4 qprinter::printerstate's. might want best avoid errors in first place. detailed description in doc states:

note setting parameters paper size , resolution on invalid printer undefined. can use qprinter::isvalid() verify before changing parameters.

additionaly, check if filename setting exists using qfile::exists. also, when setting can call , handle qprinter::supportedresolutions(), qprinter::supportedpapersources() , qprinter::supportsmultiplecopies(). of course, printing pdf might not have worry these.


Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -