QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const { #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) const Q_D(QPrinterInfo); if (isNull()) return d->paperSizes; if (!d->hasPaperSizes) { d->hasPaperSizes = true; if (QCUPSSupport::isAvailable()) { // Find paper sizes from CUPS. QCUPSSupport cups; cups.setCurrentPrinter(d->cupsPrinterIndex); const ppd_option_t* sizes = cups.pageSizes(); if (sizes) { for (int j = 0; j < sizes->num_choices; ++j) d->paperSizes.append(string2PaperSize(sizes->choices[j].choice)); } } } return d->paperSizes; #else return QList<QPrinter::PaperSize>(); #endif }
QList<QPrinter::PaperSize> QCUPSSupport::getCupsPrinterPaperSizes(int cupsPrinterIndex) { QList<QPrinter::PaperSize> result; if (!QCUPSSupport::isAvailable() || cupsPrinterIndex < 0) return result; // Find paper sizes from CUPS. QCUPSSupport cups; cups.setCurrentPrinter(cupsPrinterIndex); if (const ppd_option_t* size = cups.pageSizes()) { for (int j = 0; j < size->num_choices; ++j) result.append(string2PaperSize(size->choices[j].choice)); } return result; }