Printing without QPrintDialog (not on default printer)
-
Hi,
there is a way to print a page on a specific printer without the user interaction?I have 2 printers:
Canon XXXX
DYMO LabelWriter 450 <-- this is the default printerNow I'd like to print on a Canon XXXX directly by code and without to show the QPrintDialog.
How can I do that?I can iterate on QPrinterInfo list... but it doesn't return a QPrinter object.
QList<QPrinterInfo> plist = QPrinterInfo::availablePrinters(); qDebug() << "numbers of printers:" << plist.length(); foreach (QPrinterInfo pinfo, plist) { qDebug() << "printer name:" << pinfo.printerName(); } -
Hi,
there is a way to print a page on a specific printer without the user interaction?I have 2 printers:
Canon XXXX
DYMO LabelWriter 450 <-- this is the default printerNow I'd like to print on a Canon XXXX directly by code and without to show the QPrintDialog.
How can I do that?I can iterate on QPrinterInfo list... but it doesn't return a QPrinter object.
QList<QPrinterInfo> plist = QPrinterInfo::availablePrinters(); qDebug() << "numbers of printers:" << plist.length(); foreach (QPrinterInfo pinfo, plist) { qDebug() << "printer name:" << pinfo.printerName(); } -
Oh my god, it was so easy...
QString printerName = "Canon XXXX"; QList<QPrinterInfo> plist = QPrinterInfo::availablePrinters(); foreach (QPrinterInfo pinfo, plist) { qDebug() << "printer name:" << pinfo.printerName(); if (printerName.compare(pinfo.printerName()) == 0) { QPrinter printer(pinfo); m_report->printReport(&printer); break; } }Thank you so much @JonB
-
Oh my god, it was so easy...
QString printerName = "Canon XXXX"; QList<QPrinterInfo> plist = QPrinterInfo::availablePrinters(); foreach (QPrinterInfo pinfo, plist) { qDebug() << "printer name:" << pinfo.printerName(); if (printerName.compare(pinfo.printerName()) == 0) { QPrinter printer(pinfo); m_report->printReport(&printer); break; } }Thank you so much @JonB
-