Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 &)
 

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 20 of file qprinterinfo.h.

Constructor & Destructor Documentation

◆ QPrinterInfo() [1/3]

QPrinterInfo::QPrinterInfo ( )

Constructs an empty QPrinterInfo object.

See also
isNull()

Definition at line 64 of file qprinterinfo.cpp.

Referenced by defaultPrinter(), and printerInfo().

+ Here is the caller graph for this function:

◆ QPrinterInfo() [2/3]

QPrinterInfo::QPrinterInfo ( const QPrinterInfo & other)

Constructs a copy of other.

Definition at line 72 of file qprinterinfo.cpp.

◆ QPrinterInfo() [3/3]

QPrinterInfo::QPrinterInfo ( const QPrinter & printer)
explicit

Constructs a QPrinterInfo object from printer.

Definition at line 80 of file qprinterinfo.cpp.

References QPlatformPrinterSupportPlugin::get(), QPrinter::printerName(), and QScopedPointer< T, Cleanup >::reset().

+ Here is the call graph for this function:

◆ ~QPrinterInfo()

QPrinterInfo::~QPrinterInfo ( )

Destroys the QPrinterInfo object.

References to the values in the object become invalid.

Definition at line 105 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 362 of file qprinterinfo.cpp.

References QPlatformPrinterSupport::availablePrintDeviceIds(), and QPlatformPrinterSupportPlugin::get().

Referenced by QPrinterPrivate::findValidPrinter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References QList< T >::append(), QPlatformPrinterSupport::availablePrintDeviceIds(), QPlatformPrinterSupportPlugin::get(), list, and QList< T >::reserve().

+ Here is the call graph for this function:

◆ defaultColorMode()

QPrinter::ColorMode QPrinterInfo::defaultColorMode ( ) const

Returns the default color mode of this printer.

Since
5.13

Definition at line 327 of file qprinterinfo.cpp.

References d.

◆ defaultDuplexMode()

QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode ( ) const

Returns the default duplex mode of this printer.

Since
5.4

Definition at line 298 of file qprinterinfo.cpp.

References d.

◆ defaultPageSize()

QPageSize QPrinterInfo::defaultPageSize ( ) const

Returns the current default Page Size for this printer.

Since
5.3

Definition at line 234 of file qprinterinfo.cpp.

References d.

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

References QPrinterInfo(), QPlatformPrinterSupport::defaultPrintDeviceId(), and QPlatformPrinterSupportPlugin::get().

Referenced by QPrinterPrivate::findValidPrinter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultPrinterName()

QString QPrinterInfo::defaultPrinterName ( )
static

Returns the current default printer name.

Since
5.3

Definition at line 398 of file qprinterinfo.cpp.

References QPlatformPrinterSupport::defaultPrintDeviceId(), and QPlatformPrinterSupportPlugin::get().

+ Here is the call graph for this function:

◆ description()

QString QPrinterInfo::description ( ) const

Returns the human-readable description of the printer.

Since
5.0
See also
QPrinterInfo::printerName()

Definition at line 142 of file qprinterinfo.cpp.

References d.

◆ isDefault()

bool QPrinterInfo::isDefault ( ) const

Returns whether this printer is currently the default printer.

Definition at line 185 of file qprinterinfo.cpp.

References d.

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

References d.

◆ isRemote()

bool QPrinterInfo::isRemote ( ) const

Returns whether this printer is a remote network printer.

Since
5.3

Definition at line 196 of file qprinterinfo.cpp.

References d.

◆ location()

QString QPrinterInfo::location ( ) const

Returns the human-readable location of the printer.

Since
5.0

Definition at line 153 of file qprinterinfo.cpp.

References d.

◆ makeAndModel()

QString QPrinterInfo::makeAndModel ( ) const

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

Since
5.0

Definition at line 164 of file qprinterinfo.cpp.

References d.

◆ maximumPhysicalPageSize()

QPageSize QPrinterInfo::maximumPhysicalPageSize ( ) const

Returns the maximum physical page size supported by this printer.

See also
minimumPhysicalPageSize()
Since
5.3

Definition at line 274 of file qprinterinfo.cpp.

References d, and QPageSize::ExactMatch.

◆ minimumPhysicalPageSize()

QPageSize QPrinterInfo::minimumPhysicalPageSize ( ) const

Returns the minimum physical page size supported by this printer.

See also
maximumPhysicalPageSize()
Since
5.3

Definition at line 260 of file qprinterinfo.cpp.

References d, and QPageSize::ExactMatch.

◆ operator=()

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

+ Here is the call graph for this function:

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

References QPrinterInfo(), and printerName().

Referenced by QPrinterPrivate::findValidPrinter(), and QPrinter::setPrinterName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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

References d.

Referenced by printerInfo().

+ Here is the caller graph for this function:

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

References d.

◆ supportedColorModes()

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

Returns the supported color modes of this printer.

Since
5.13

Definition at line 339 of file qprinterinfo.cpp.

References d, list, QList< T >::reserve(), and supportedColorModes().

Referenced by supportedColorModes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportedDuplexModes()

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

Returns a list of duplex modes supported by this printer.

Since
5.4

Definition at line 310 of file qprinterinfo.cpp.

References d, list, QList< T >::reserve(), and supportedDuplexModes().

Referenced by supportedDuplexModes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportedPageSizes()

QList< QPageSize > QPrinterInfo::supportedPageSizes ( ) const

Returns a list of Page Sizes supported by this printer.

Since
5.3

Definition at line 222 of file qprinterinfo.cpp.

References d.

◆ supportedResolutions()

QList< int > QPrinterInfo::supportedResolutions ( ) const

Returns a list of resolutions supported by this printer.

Since
5.3

Definition at line 286 of file qprinterinfo.cpp.

References d.

◆ supportsCustomPageSizes()

bool QPrinterInfo::supportsCustomPageSizes ( ) const

Returns whether this printer supports custom page sizes.

Since
5.3

Definition at line 246 of file qprinterinfo.cpp.

References d.

Friends And Related Symbol Documentation

◆ operator<<

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

Definition at line 443 of file qprinterinfo.cpp.

◆ QPlatformPrinterSupport

friend class QPlatformPrinterSupport
friend

Definition at line 69 of file qprinterinfo.h.


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