Printer information support
As a relatively new Trolltech employee (this is my first post!), I was thrown into Qt’s printing framework, with the hopes of improving some of the long standing issues.
One of the problems with printing using Qt today isn’t actually printing itself, but rather information about printers. The current framework is very opaque; typically a programmer just has to set a printer name on a QPrinter object, start painting and hope that it reaches some printer out there. The only way to reliably select a printer is by using QPrintDialog and let the user select it there. However, the programmer cannot influence the appearance or behavior of the dialog, nor can he/she automate the choice of printers.
With this in mind, we started working on a new class, QPrinterInfo, whose task is to provide information about the printers that are installed on the system. Some API decisions are yet to be made, but users will be able to query for installed printers, which printer is the default, and what paper sizes each printer supports.
Here is an example of how you can list the printers on a system:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDialog dialog;
QLayout* layout = new QGridLayout;
QPushButton* ok = new QPushButton(QLatin1String("OK"));
QLabel* text = new QLabel;
layout->addWidget(text);
layout->addWidget(ok);
dialog.setLayout(layout);
QList<QPrinterInfo> printerList = QPrinterInfo::availablePrinters();
QString printers("Printers:n");
for (int c = 0; c < printerList.size(); ++c) {
printers += printerList[c].printerName();
printers += QLatin1String("n");
}
printers += "nDefault:n";
printers += QPrinterInfo::defaultPrinter().printerName();
text->setText(printers);
QObject::connect(ok, SIGNAL(clicked()), &dialog, SLOT(accept()));
dialog.show();
dialog.exec();
return 0;
}
More on Qt
- Security advisory: Multiple third-party Chromium vulnerabilities fixed in Chrome 153.0.8010.52 impact Qt WebEngine
- Security advisory: Multiple third-party Chromium vulnerabilities fixed in Chrome 154.0.8037.93 impact Qt WebEngine
- Security advisory: CVE-2026-118968: Denial-of-service vulnerability in WAV audio decoding impacts Qt