QPrinterInfo Class

The QPrinterInfo class gives access to information about existing printers. More...

Header: #include <QPrinterInfo>
qmake: QT += printsupport
Since: Qt 4.4

Public Functions

QPrinterInfo()
QPrinterInfo(const QPrinterInfo & other)
QPrinterInfo(const QPrinter & printer)
~QPrinterInfo()
QString description() const
bool isDefault() const
bool isNull() const
QString location() const
QString makeAndModel() const
QString printerName() const
QList<QPrinter::PaperSize> supportedPaperSizes() const
QList<QPair<QString, QSizeF> > supportedSizesWithNames() const
QPrinterInfo & operator=(const QPrinterInfo & other)

Static Public Members

QList<QPrinterInfo> availablePrinters()
QPrinterInfo defaultPrinter()
QPrinterInfo printerInfo(const QString & printerName)

Detailed Description

The QPrinterInfo class gives access to information about existing printers.

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.

Member Function Documentation

QPrinterInfo::QPrinterInfo()

Constructs an empty QPrinterInfo object.

See also isNull().

QPrinterInfo::QPrinterInfo(const QPrinterInfo & other)

Constructs a copy of other.

QPrinterInfo::QPrinterInfo(const QPrinter & printer)

Constructs a QPrinterInfo object from printer.

QPrinterInfo::~QPrinterInfo()

Destroys the QPrinterInfo object. References to the values in the object become invalid.

QList<QPrinterInfo> QPrinterInfo::availablePrinters() [static]

Returns a list of available printers on the system.

QPrinterInfo QPrinterInfo::defaultPrinter() [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.

See also isNull(), isDefault(), and availablePrinters().

QString QPrinterInfo::description() const

Returns the human-readable description of the printer.

This function was introduced in Qt 5.0.

See also QPrinterInfo::printerName().

bool QPrinterInfo::isDefault() const

Returns whether this printer is the default printer.

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.

QString QPrinterInfo::location() const

Returns the human-readable location of the printer.

This function was introduced in Qt 5.0.

QString QPrinterInfo::makeAndModel() const

Returns the human-readable make and model of the printer.

This function was introduced in Qt 5.0.

QPrinterInfo QPrinterInfo::printerInfo(const QString & printerName) [static]

Returns the printer printerName.

The return value should be checked using isNull() before being used, in case the named printer does not exist.

This function was introduced in Qt 5.0.

See also isNull().

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.

See also QPrinterInfo::description() and QPrinter::setPrinterName().

QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const

Returns a list of supported paper sizes by the printer.

Not all printer drivers support this query, so the list may be empty. On Mac OS X 10.3, this function always returns an empty list.

This function was introduced in Qt 4.4.

QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const

Returns a list of all the paper names supported by the driver with the corresponding size in millimeters.

Not all printer drivers support this query, so the list may be empty.

This function was introduced in Qt 5.1.

QPrinterInfo & QPrinterInfo::operator=(const QPrinterInfo & other)

Sets the QPrinterInfo object to be equal to other.