I wan't to remove under Linux, "Write to PDF" from printers list in QPrinter settings dialog that is called, when printing document from QPrintPreviewDialog. Is it possible to do?
I've tried replacing print icon inside QPrintPreviewDialog with my own button and action, but still Qt shows standard QPrinter dialog, and I don't know how to remove "Write to PDF" from printers list in that dialog.
Short answer: no, there's no way to alter the printers list in the default print dialog.
Workaround: if the user choose that "Print to file" option, don't print anything (and maybe tell them they won't have a PDF from your app).
You can do it this way: connect the QPrintPreviewDialog::paintRequested
signal to a slot like this:
void Widget::onPaintRequested(QPrinter *printer)
{
QVariant printername = printer->printEngine()->property(QPrintEngine::PPK_PrinterName);
if(printername.toString().isEmpty())
{
QMessageBox::information(this, "Print issue", "Print to file is not available for weird unknown reasons ...");
}
else
{
//supply the requested paint code
}
}
Some more (maybe inspiring) thoughts on the topic in the answer to this SO question.