QPrinterInfo QPrinterInfo::defaultPrinter() { QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) return QPrinterInfo(ps->defaultPrintDeviceId()); return QPrinterInfo(); }
/*! Returns the printer \a printerName. The return value should be checked using isNull() before being used, in case the named printer does not exist. \since 5.0 \sa isNull() */ QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName) { QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (!ps) return QPrinterInfo(); return ps->printerInfo(printerName); }
QList<QPrinterInfo> QPrinterInfo::availablePrinters() { QList<QPrinterInfo> printers; #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) if (QCUPSSupport::isAvailable()) { QCUPSSupport cups; int cupsPrinterCount = cups.availablePrintersCount(); const cups_dest_t* cupsPrinters = cups.availablePrinters(); for (int i = 0; i < cupsPrinterCount; ++i) { QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name)); if (cupsPrinters[i].instance) printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); QPrinterInfo printerInfo(printerName); if (cupsPrinters[i].is_default) printerInfo.d_ptr->isDefault = true; printerInfo.d_ptr->cupsPrinterIndex = i; printers.append(printerInfo); } } else #endif { QList<QPrinterDescription> lprPrinters; int defprn = qt_getLprPrinters(lprPrinters); // populating printer combo foreach (const QPrinterDescription &description, lprPrinters) printers.append(QPrinterInfo(description.name)); if (defprn >= 0 && defprn < printers.size()) printers[defprn].d_ptr->isDefault = true; } return printers; }
QPrinterInfo QPlatformPrinterSupport::printerInfo(const QString &printerName) { const QList<QPrinterInfo> printers = availablePrinters(); foreach (const QPrinterInfo &printerInfo, printers) { if (printerInfo.printerName() == printerName) return printerInfo; } return QPrinterInfo(); }
QPrinterInfo QPlatformPrinterSupport::defaultPrinter() { const QList<QPrinterInfo> printers = availablePrinters(); foreach (const QPrinterInfo &printerInfo, printers) { if (printerInfo.isDefault()) return printerInfo; } return QPrinterInfo(); }
/*! Returns a list of QPrinterInfo objects for all the available printers on this system. It is NOT recommended to use this as creating each printer instance may take a long time, especially if there are remote networked printers, and retained instances may become outdated if changes are made on the local system or remote print server. Use availablePrinterNames() instead and only instantiate printer instances as you need them. */ QList<QPrinterInfo> QPrinterInfo::availablePrinters() { QList<QPrinterInfo> list; QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) { foreach (const QString &id, ps->availablePrintDeviceIds()) list.append(QPrinterInfo(id)); } return list; }
QPrinterInfo QPrinterInfo::defaultPrinter() { QString noPrinters(QLatin1String("qt_no_printers")); wchar_t buffer[256]; GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256); QString output = QString::fromWCharArray(buffer); if (output != noPrinters) { // Filter out the name of the printer, which should be everything before a comma. QString printerName = output.split(QLatin1Char(',')).value(0); QPrinterInfo printerInfo(printerName); printerInfo.d_ptr->isDefault = true; return printerInfo; } return QPrinterInfo(); }
+ "<font size=\"+2\">" + QString::number(m_totalcost, 'g', 6) + "</font> " + QObject::tr("总项数: ") + "<font size=\"+1\">" + QString::number(m_totalitems, 'g', 6) + "</font></div>"; m_html += "<div align=\"center\">" + QObject::tr("预收: ") + "<font size=\"+2\">" + QString::number(m_totalget, 'g', 6) + "</font> " + QObject::tr("找零: ") + "<font size=\"+2\">" + QString::number(m_totalget-m_totalcost, 'g', 6) + "</font></div>"; m_html += "<p align=\"center\">" + QObject::tr("*淘米欢迎您再次光临*") + "</p>"; m_html += "<div align=\"center\">" + QObject::tr("服务热线: 88888888") + "</div>"; //debug: to get the html content qDebug(m_html.toUtf8()); //debug: to get available printer in local area QString m_printers = Printer::printerList(); qDebug(m_printers.toUtf8()); //find the wanted network printer to print QPrinterInfo printerInfo = QPrinterInfo(); QPrinterInfo targetPrinterInfo = QPrinterInfo(); foreach(QPrinterInfo item, printerInfo.availablePrinters()){ if(item.printerName() == QString::fromStdString("HP_LaserJet_P4014.P4015_PCL6:3")){ //m_printer = new QPrinter(item, QPrinter::HighResolution); targetPrinterInfo = item; qDebug(targetPrinterInfo.printerName().toUtf8()); break; }else{ qDebug("nothing!!!"); } } //QPrinter m_printer(targetPrinterInfo, QPrinter::HighResolution); QPrinter m_printer(QPrinter::HighResolution);
/*! Returns the printer \a printerName. The return value should be checked using isNull() before being used, in case the named printer does not exist. \since 5.0 \sa isNull() */ QPrinterInfo QPrinterInfo::printerInfo(const QString &printerName) { return QPrinterInfo(printerName); }