![]() |
Qt 6.x
The Qt SDK
|
The QPrinterInfo class gives access to information about existing printers. More...
#include <qprinterinfo.h>
Public Member Functions | |
QPrinterInfo () | |
Constructs an empty QPrinterInfo object. | |
QPrinterInfo (const QPrinterInfo &other) | |
Constructs a copy of other. | |
QPrinterInfo (const QPrinter &printer) | |
Constructs a QPrinterInfo object from printer. | |
~QPrinterInfo () | |
Destroys the QPrinterInfo object. | |
QPrinterInfo & | operator= (const QPrinterInfo &other) |
Sets the QPrinterInfo object to be equal to other. | |
QString | printerName () const |
Returns the name of the printer. | |
QString | description () const |
Returns the human-readable description of the printer. | |
QString | location () const |
Returns the human-readable location of the printer. | |
QString | makeAndModel () const |
Returns the human-readable make and model of the printer. | |
bool | isNull () const |
Returns whether this QPrinterInfo object holds a printer definition. | |
bool | isDefault () const |
Returns whether this printer is currently the default printer. | |
bool | isRemote () const |
Returns whether this printer is a remote network printer. | |
QPrinter::PrinterState | state () const |
Returns the current state of this printer. | |
QList< QPageSize > | supportedPageSizes () const |
Returns a list of Page Sizes supported by this printer. | |
QPageSize | defaultPageSize () const |
Returns the current default Page Size for this printer. | |
bool | supportsCustomPageSizes () const |
Returns whether this printer supports custom page sizes. | |
QPageSize | minimumPhysicalPageSize () const |
Returns the minimum physical page size supported by this printer. | |
QPageSize | maximumPhysicalPageSize () const |
Returns the maximum physical page size supported by this printer. | |
QList< int > | supportedResolutions () const |
Returns a list of resolutions supported by this printer. | |
QPrinter::DuplexMode | defaultDuplexMode () const |
Returns the default duplex mode of this printer. | |
QList< QPrinter::DuplexMode > | supportedDuplexModes () const |
Returns a list of duplex modes supported by this printer. | |
QPrinter::ColorMode | defaultColorMode () const |
Returns the default color mode of this printer. | |
QList< QPrinter::ColorMode > | supportedColorModes () const |
Returns the supported color modes of this printer. | |
Static Public Member Functions | |
static QStringList | availablePrinterNames () |
Returns a list of all the available Printer Names on this system. | |
static QList< QPrinterInfo > | availablePrinters () |
Returns a list of QPrinterInfo objects for all the available printers on this system. | |
static QString | defaultPrinterName () |
Returns the current default printer name. | |
static QPrinterInfo | defaultPrinter () |
Returns the default printer on the system. | |
static QPrinterInfo | printerInfo (const QString &printerName) |
Returns the printer printerName. | |
Friends | |
class | QPlatformPrinterSupport |
Q_PRINTSUPPORT_EXPORT QDebug | operator<< (QDebug debug, const QPrinterInfo &) |
The QPrinterInfo class gives access to information about existing printers.
\inmodule QtPrintSupport
Use the static functions to generate a list of QPrinterInfo objects. Each QPrinterInfo object in the list represents a single printer and can be queried for name, supported paper sizes, and whether or not it is the default printer.
Definition at line 21 of file qprinterinfo.h.
QPrinterInfo::QPrinterInfo | ( | ) |
Constructs an empty QPrinterInfo object.
Definition at line 64 of file qprinterinfo.cpp.
Referenced by defaultPrinter(), and printerInfo().
QPrinterInfo::QPrinterInfo | ( | const QPrinterInfo & | other | ) |
Constructs a copy of other.
Definition at line 72 of file qprinterinfo.cpp.
|
explicit |
Constructs a QPrinterInfo object from printer.
Definition at line 80 of file qprinterinfo.cpp.
References QPlatformPrinterSupportPlugin::get(), pi, QPrinter::printerName(), and QScopedPointer< T, Cleanup >::reset().
QPrinterInfo::~QPrinterInfo | ( | ) |
Destroys the QPrinterInfo object.
References to the values in the object become invalid.
Definition at line 105 of file qprinterinfo.cpp.
|
static |
Returns a list of all the available Printer Names on this system.
It is recommended to use this instead of availablePrinters() as it will be faster on most systems.
Note that the list may become outdated if changes are made on the local system or remote print server. Only instantiate required QPrinterInfo instances when needed, and always check for validity before calling.
Definition at line 362 of file qprinterinfo.cpp.
References QPlatformPrinterSupport::availablePrintDeviceIds(), and QPlatformPrinterSupportPlugin::get().
Referenced by QPrinterPrivate::findValidPrinter().
|
static |
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.
Definition at line 380 of file qprinterinfo.cpp.
References QList< T >::append(), QPlatformPrinterSupport::availablePrintDeviceIds(), QPlatformPrinterSupportPlugin::get(), list, and QList< T >::reserve().
QPrinter::ColorMode QPrinterInfo::defaultColorMode | ( | ) | const |
Returns the default color mode of this printer.
Definition at line 327 of file qprinterinfo.cpp.
References d.
QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode | ( | ) | const |
Returns the default duplex mode of this printer.
Definition at line 298 of file qprinterinfo.cpp.
References d.
QPageSize QPrinterInfo::defaultPageSize | ( | ) | const |
Returns the current default Page Size for this printer.
Definition at line 234 of file qprinterinfo.cpp.
References d.
|
static |
Returns the default printer on the system.
The return value should be checked using isNull() before being used, in case there is no default printer.
On some systems it is possible for there to be available printers but none of them set to be the default printer.
Definition at line 420 of file qprinterinfo.cpp.
References QPrinterInfo(), QPlatformPrinterSupport::defaultPrintDeviceId(), and QPlatformPrinterSupportPlugin::get().
Referenced by QPrinterPrivate::findValidPrinter().
|
static |
Returns the current default printer name.
Definition at line 398 of file qprinterinfo.cpp.
References QPlatformPrinterSupport::defaultPrintDeviceId(), and QPlatformPrinterSupportPlugin::get().
QString QPrinterInfo::description | ( | ) | const |
Returns the human-readable description of the printer.
Definition at line 142 of file qprinterinfo.cpp.
References d.
bool QPrinterInfo::isDefault | ( | ) | const |
Returns whether this printer is currently the default printer.
Definition at line 185 of file qprinterinfo.cpp.
References d.
bool QPrinterInfo::isNull | ( | ) | const |
Returns whether this QPrinterInfo object holds a printer definition.
An empty QPrinterInfo object could result for example from calling defaultPrinter() when there are no printers on the system.
Definition at line 176 of file qprinterinfo.cpp.
References d.
Referenced by QPrinterPrivate::findValidPrinter(), QPrinterPrivate::initEngines(), QPrinter::setOutputFormat(), and QPrinter::setPrinterName().
bool QPrinterInfo::isRemote | ( | ) | const |
Returns whether this printer is a remote network printer.
Definition at line 196 of file qprinterinfo.cpp.
References d.
QString QPrinterInfo::location | ( | ) | const |
Returns the human-readable location of the printer.
Definition at line 153 of file qprinterinfo.cpp.
References d.
QString QPrinterInfo::makeAndModel | ( | ) | const |
Returns the human-readable make and model of the printer.
Definition at line 164 of file qprinterinfo.cpp.
References d.
QPageSize QPrinterInfo::maximumPhysicalPageSize | ( | ) | const |
Returns the maximum physical page size supported by this printer.
Definition at line 274 of file qprinterinfo.cpp.
References d, and QPageSize::ExactMatch.
QPageSize QPrinterInfo::minimumPhysicalPageSize | ( | ) | const |
Returns the minimum physical page size supported by this printer.
Definition at line 260 of file qprinterinfo.cpp.
References d, and QPageSize::ExactMatch.
QPrinterInfo & QPrinterInfo::operator= | ( | const QPrinterInfo & | other | ) |
Sets the QPrinterInfo object to be equal to other.
Definition at line 112 of file qprinterinfo.cpp.
References other(), Q_ASSERT, and QScopedPointer< T, Cleanup >::reset().
|
static |
Returns the printer printerName.
The return value should be checked using isNull() before being used, in case the named printer does not exist.
Definition at line 437 of file qprinterinfo.cpp.
References QPrinterInfo(), and printerName().
Referenced by QPrinterPrivate::findValidPrinter(), and QPrinter::setPrinterName().
QString QPrinterInfo::printerName | ( | ) | const |
Returns the name of the printer.
This is a unique id to identify the printer and may not be human-readable.
Definition at line 130 of file qprinterinfo.cpp.
References d.
Referenced by QPrinterPrivate::initEngines(), and printerInfo().
QPrinter::PrinterState QPrinterInfo::state | ( | ) | const |
Returns the current state of this printer.
This state may not always be accurate, depending on the platform, printer driver, or printer itself.
Definition at line 210 of file qprinterinfo.cpp.
References d.
QList< QPrinter::ColorMode > QPrinterInfo::supportedColorModes | ( | ) | const |
Returns the supported color modes of this printer.
Definition at line 339 of file qprinterinfo.cpp.
References d, list, QList< T >::reserve(), and supportedColorModes().
Referenced by supportedColorModes().
QList< QPrinter::DuplexMode > QPrinterInfo::supportedDuplexModes | ( | ) | const |
Returns a list of duplex modes supported by this printer.
Definition at line 310 of file qprinterinfo.cpp.
References d, list, QList< T >::reserve(), and supportedDuplexModes().
Referenced by supportedDuplexModes().
Returns a list of Page Sizes supported by this printer.
Definition at line 222 of file qprinterinfo.cpp.
References d.
QList< int > QPrinterInfo::supportedResolutions | ( | ) | const |
Returns a list of resolutions supported by this printer.
Definition at line 286 of file qprinterinfo.cpp.
References d.
bool QPrinterInfo::supportsCustomPageSizes | ( | ) | const |
Returns whether this printer supports custom page sizes.
Definition at line 246 of file qprinterinfo.cpp.
References d.
|
friend |
Definition at line 443 of file qprinterinfo.cpp.
|
friend |
Definition at line 70 of file qprinterinfo.h.