Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QPrinterInfo Class Reference

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

#include <qprinterinfo.h>

Collaboration diagram for QPrinterInfo:

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.
QPrinterInfooperator= (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< QPageSizesupportedPageSizes () 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::DuplexModesupportedDuplexModes () 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::ColorModesupportedColorModes () 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< QPrinterInfoavailablePrinters ()
 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 &p)

Detailed Description

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.

Since
4.4

Definition at line 21 of file qprinterinfo.h.

Constructor & Destructor Documentation

◆ QPrinterInfo() [1/3]

QPrinterInfo::QPrinterInfo ( )

Constructs an empty QPrinterInfo object.

See also
isNull()

Definition at line 61 of file qprinterinfo.cpp.

◆ QPrinterInfo() [2/3]

QPrinterInfo::QPrinterInfo ( const QPrinterInfo & other)

Constructs a copy of other.

Definition at line 69 of file qprinterinfo.cpp.

◆ QPrinterInfo() [3/3]

QPrinterInfo::QPrinterInfo ( const QPrinter & printer)
explicit

Constructs a QPrinterInfo object from printer.

Definition at line 77 of file qprinterinfo.cpp.

◆ ~QPrinterInfo()

QPrinterInfo::~QPrinterInfo ( )

Destroys the QPrinterInfo object.

References to the values in the object become invalid.

Definition at line 102 of file qprinterinfo.cpp.

Member Function Documentation

◆ availablePrinterNames()

QStringList QPrinterInfo::availablePrinterNames ( )
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.

Since
5.3

Definition at line 359 of file qprinterinfo.cpp.

◆ availablePrinters()

QList< QPrinterInfo > QPrinterInfo::availablePrinters ( )
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 377 of file qprinterinfo.cpp.

◆ defaultColorMode()

QPrinter::ColorMode QPrinterInfo::defaultColorMode ( ) const

Returns the default color mode of this printer.

Since
5.13

Definition at line 324 of file qprinterinfo.cpp.

◆ defaultDuplexMode()

QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode ( ) const

Returns the default duplex mode of this printer.

Since
5.4

Definition at line 295 of file qprinterinfo.cpp.

◆ defaultPageSize()

QPageSize QPrinterInfo::defaultPageSize ( ) const

Returns the current default Page Size for this printer.

Since
5.3

Definition at line 231 of file qprinterinfo.cpp.

◆ defaultPrinter()

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()
availablePrinters()

Definition at line 417 of file qprinterinfo.cpp.

◆ defaultPrinterName()

QString QPrinterInfo::defaultPrinterName ( )
static

Returns the current default printer name.

Since
5.3

Definition at line 395 of file qprinterinfo.cpp.

◆ description()

QString QPrinterInfo::description ( ) const

Returns the human-readable description of the printer.

Since
5.0
See also
QPrinterInfo::printerName()

Definition at line 139 of file qprinterinfo.cpp.

◆ isDefault()

bool QPrinterInfo::isDefault ( ) const

Returns whether this printer is currently the default printer.

Definition at line 182 of file qprinterinfo.cpp.

◆ isNull()

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 173 of file qprinterinfo.cpp.

◆ isRemote()

bool QPrinterInfo::isRemote ( ) const

Returns whether this printer is a remote network printer.

Since
5.3

Definition at line 193 of file qprinterinfo.cpp.

◆ location()

QString QPrinterInfo::location ( ) const

Returns the human-readable location of the printer.

Since
5.0

Definition at line 150 of file qprinterinfo.cpp.

◆ makeAndModel()

QString QPrinterInfo::makeAndModel ( ) const

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

Since
5.0

Definition at line 161 of file qprinterinfo.cpp.

◆ maximumPhysicalPageSize()

QPageSize QPrinterInfo::maximumPhysicalPageSize ( ) const

Returns the maximum physical page size supported by this printer.

See also
minimumPhysicalPageSize()
Since
5.3

Definition at line 271 of file qprinterinfo.cpp.

◆ minimumPhysicalPageSize()

QPageSize QPrinterInfo::minimumPhysicalPageSize ( ) const

Returns the minimum physical page size supported by this printer.

See also
maximumPhysicalPageSize()
Since
5.3

Definition at line 257 of file qprinterinfo.cpp.

◆ operator=()

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

Sets the QPrinterInfo object to be equal to other.

Definition at line 109 of file qprinterinfo.cpp.

◆ printerInfo()

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.

Since
5.0
See also
isNull()

Definition at line 434 of file qprinterinfo.cpp.

◆ printerName()

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()
QPrinter::setPrinterName()

Definition at line 127 of file qprinterinfo.cpp.

◆ state()

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.

Since
5.3

Definition at line 207 of file qprinterinfo.cpp.

◆ supportedColorModes()

QList< QPrinter::ColorMode > QPrinterInfo::supportedColorModes ( ) const

Returns the supported color modes of this printer.

Since
5.13

Definition at line 336 of file qprinterinfo.cpp.

◆ supportedDuplexModes()

QList< QPrinter::DuplexMode > QPrinterInfo::supportedDuplexModes ( ) const

Returns a list of duplex modes supported by this printer.

Since
5.4

Definition at line 307 of file qprinterinfo.cpp.

◆ supportedPageSizes()

QList< QPageSize > QPrinterInfo::supportedPageSizes ( ) const

Returns a list of Page Sizes supported by this printer.

Since
5.3

Definition at line 219 of file qprinterinfo.cpp.

◆ supportedResolutions()

QList< int > QPrinterInfo::supportedResolutions ( ) const

Returns a list of resolutions supported by this printer.

Since
5.3

Definition at line 283 of file qprinterinfo.cpp.

◆ supportsCustomPageSizes()

bool QPrinterInfo::supportsCustomPageSizes ( ) const

Returns whether this printer supports custom page sizes.

Since
5.3

Definition at line 243 of file qprinterinfo.cpp.

◆ operator<<

Q_PRINTSUPPORT_EXPORT QDebug operator<< ( QDebug debug,
const QPrinterInfo & p )
friend

Definition at line 440 of file qprinterinfo.cpp.

◆ QPlatformPrinterSupport

friend class QPlatformPrinterSupport
friend

Definition at line 70 of file qprinterinfo.h.


The documentation for this class was generated from the following files: