Sounds good, thanks again!
EDIT: A quick note for anyone else having the problem, ussing just QPrinterInfo::isNull() didn't help because that only seems to return true if there are no printers at all on the system (and still returns false if there is no default printer set) so I had to check the printer's name too:
QPrinterInfo def = QPrinterInfo::defaultPrinter();
//if there is no default printer set the print preview won't show
if(def.isNull() || def.printerName().isEmpty())
{
if(QPrinterInfo::availablePrinters().isEmpty())
{
QMessageBox::critical(this, tr
("Print error"), tr
("Cannot proceed because there are no available printers in your system."),
QMessageBox::Ok);
}
else
{
def = QPrinterInfo::availablePrinters().first();
}
}
.....
QPrinterInfo def = QPrinterInfo::defaultPrinter();
//if there is no default printer set the print preview won't show
if(def.isNull() || def.printerName().isEmpty())
{
if(QPrinterInfo::availablePrinters().isEmpty())
{
QMessageBox::critical(this, tr("Print error"), tr("Cannot proceed because there are no available printers in your system."), QMessageBox::Ok);
}
else
{
def = QPrinterInfo::availablePrinters().first();
}
}
QPrinter printer(def, QPrinter::ScreenResolution);
.....
To copy to clipboard, switch view to plain text mode
Bookmarks