QList<QPrinterInfo> pil = QPrinterInfo::availablePrinters();
for (int i = 0; i < pil.size(); i++)
{
QPrinterInfo pi = pil.at(i);
qDebug("printer name=%s", qUtf8Printable(pi.printerName()));
QList<QPageSize> psl = pi.supportedPageSizes();
for (int j = 0; j < psl.size(); j++)
{
QPageSize psz = psl.at(j);
QSizeF page_size
= psz.
definitionSize();
QPageSize::Unit page_unit = psz.definitionUnits();
qDebug("page size = %s (%.3f%s x %.3f%s)", qUtf8Printable(psz.name()), page_size.width(), qUtf8Printable(ul.at(page_unit)), page_size.height(), qUtf8Printable(ul.at(page_unit)));
}
}
QList<QPrinterInfo> pil = QPrinterInfo::availablePrinters();
QStringList ul = {"mm", "p", "in", "pc", "dd", "ci"};
for (int i = 0; i < pil.size(); i++)
{
QPrinterInfo pi = pil.at(i);
qDebug("printer name=%s", qUtf8Printable(pi.printerName()));
QList<QPageSize> psl = pi.supportedPageSizes();
for (int j = 0; j < psl.size(); j++)
{
QPageSize psz = psl.at(j);
QSizeF page_size = psz.definitionSize();
QPageSize::Unit page_unit = psz.definitionUnits();
qDebug("page size = %s (%.3f%s x %.3f%s)", qUtf8Printable(psz.name()), page_size.width(), qUtf8Printable(ul.at(page_unit)), page_size.height(), qUtf8Printable(ul.at(page_unit)));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks