- Qt 5.15
- Qt Print Support
- C++ Classes
- QPrinter
- Qt 5.15.18 Reference Documentation

# Obsolete Members for QPrinter

The following members of class QPrinter are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(obsolete)` int | actualNumCopies() const
`(obsolete)` bool | doubleSidedPrinting() const
`(obsolete)` void | getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const
`(obsolete)` int | numCopies() const
`(obsolete)` Orientation | orientation() const
`(obsolete)` QRect | pageRect() const
`(obsolete)` PageSize | pageSize() const
`(obsolete)` QString | paperName() const
`(obsolete)` QRect | paperRect() const
`(obsolete)` PaperSize | paperSize() const
`(obsolete)` QSizeF | paperSize(Unit unit) const
`(obsolete)` void | setDoubleSidedPrinting(bool doubleSided)
`(obsolete)` void | setNumCopies(int numCopies)
`(obsolete)` void | setOrientation(Orientation orientation)
`(obsolete)` void | setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)
`(obsolete)` void | setPaperName(const QString &paperName)
`(obsolete)` void | setPaperSize(PaperSize newPaperSize)
`(obsolete)` void | setPaperSize(const QSizeF &paperSize, Unit unit)
`(obsolete)` void | setWinPageSize(int pageSize)
`(obsolete)` int | winPageSize() const

## Member Function Documentation

### int QPrinter::actualNumCopies() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the number of copies that will be printed. The default value is 1.

This function always returns the actual value specified in the print dialog or using setNumCopies().

Use copyCount() instead.

This function was introduced in Qt 4.6.

See also setNumCopies() and numCopies().

### bool QPrinter::doubleSidedPrinting() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use duplex() instead.

Returns `true` if double side printing is enabled.

This function was introduced in Qt 4.2.

See also setDoubleSidedPrinting() and duplex().

### void QPrinter::getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().margins() instead.

Returns the page margins for this printer in left, top, right, bottom. The unit of the returned margins are specified with the unit parameter.

This function was introduced in Qt 4.4.

See also pageLayout() and setPageMargins().

### int QPrinter::numCopies() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Returns the number of copies to be printed. The default value is 1.

On Windows, macOS and X11 systems that support CUPS, this will always return 1 as these operating systems can internally handle the number of copies.

On X11, this value will return the number of times the application is required to print in order to match the number specified in the printer setup dialog. This has been done since some printer drivers are not capable of buffering up the copies and in those cases the application must make an explicit call to the print code for each copy.

Use copyCount() in conjunction with supportsMultipleCopies() instead.

See also setNumCopies() and actualNumCopies().

### Orientation QPrinter::orientation() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().orientation() instead.

Returns the orientation setting. This is driver-dependent, but is usually QPrinter::Portrait.

See also setOrientation() and pageLayout().

### QRect QPrinter::pageRect() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().paintRectPixels(resolution()) instead.

Returns the page's rectangle; this is usually smaller than the paperRect() since the page normally has margins between its borders and the paper.

The unit of the returned rectangle is DevicePixel.

See also pageLayout().

### PageSize QPrinter::pageSize() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().pageSize().id() instead.

Returns the printer page size. The default value is driver-dependent.

See also setPageSize() and pageLayout().

### QString QPrinter::paperName() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().pageSize().name() instead.

Returns the paper name of the paper set on the printer.

The default value for this is driver-dependent.

This function was introduced in Qt 5.1.

See also setPaperName() and pageLayout().

### QRect QPrinter::paperRect() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().fullRectPixels(resolution()) instead.

Returns the paper's rectangle; this is usually larger than the pageRect().

The unit of the returned rectangle is DevicePixel.

See also pageLayout().

### PaperSize QPrinter::paperSize() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().pageSize().id() instead.

Returns the printer paper size. The default value is driver-dependent.

This function was introduced in Qt 4.4.

See also setPaperSize() and pageLayout().

### QSizeF QPrinter::paperSize(Unit unit) const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout().pageSize().size() or pageLayout().fullPageSize() instead.

Returns the paper size in unit.

Note that the returned size reflects the current paper orientation.

This function was introduced in Qt 4.4.

See also pageLayout().

### void QPrinter::setDoubleSidedPrinting(bool doubleSided)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setDuplex() instead.

Enables double sided printing if doubleSided is true; otherwise disables it.

This function was introduced in Qt 4.2.

See also doubleSidedPrinting() and setDuplex().

### `[override virtual]` void QPrinter::setMargins(const Margins &m)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Reimplements: QPagedPaintDevice::setMargins(const Margins &margins).

Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.

See also setPageMargins().

### void QPrinter::setNumCopies(int numCopies)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Sets the number of copies to be printed to numCopies.

The printer driver reads this setting and prints the specified number of copies.

Use setCopyCount() instead.

See also numCopies().

### void QPrinter::setOrientation(Orientation orientation)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setPageOrientation() instead.

Sets the print orientation to orientation.

The orientation can be either QPrinter::Portrait or QPrinter::Landscape.

The printer driver reads this setting and prints using the specified orientation.

On Windows and Mac, this option can be changed while printing and will take effect from the next call to newPage().

See also orientation() and setPageOrientation().

### void QPrinter::setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setPageMargins(QMarginsF, QPageLayout::Unit) instead.

This function sets the left, top, right and bottom page margins for this printer. The unit of the margins are specified with the unit parameter.

This function was introduced in Qt 4.4.

See also setPageMargins().

### `[override virtual]` void QPrinter::setPageSize(PageSize newPageSize)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Reimplements: QPagedPaintDevice::setPageSize(PageSize size).

Use setPageSize(QPageSize) instead.

Sets the printer page size based on newPageSize.

See also setPageSize().

### `[override virtual]` void QPrinter::setPageSizeMM(const QSizeF &size)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Reimplements: QPagedPaintDevice::setPageSizeMM(const QSizeF &size).

Use setPageSize(QPageSize) instead.

Use setPageSize(QPageSize) instead.

Note that the page size is defined in a portrait layout, regardless of what the current printer orientation is set to.

See also setPageSize().

### void QPrinter::setPaperName(const QString &paperName)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setPageSize(QPageSize) instead.

Sets the paper used by the printer to paperName.

This function was introduced in Qt 5.1.

See also paperName() and setPageSize().

### void QPrinter::setPaperSize(PaperSize newPaperSize)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setPageSize(QPageSize) instead.

Sets the printer paper size to newPaperSize if that size is supported. The result is undefined if newPaperSize is not supported.

The default paper size is driver-dependent.

This function is useful mostly for setting a default value that the user can override in the print dialog.

This function was introduced in Qt 4.4.

See also paperSize() and setPageSize().

### void QPrinter::setPaperSize(const QSizeF &paperSize, Unit unit)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setPageSize(QPageSize) instead.

Sets the paper size based on paperSize in unit.

Note that the paper size is defined in a portrait layout, regardless of what the current printer orientation is set to.

This function was introduced in Qt 4.4.

See also setPageSize().

### void QPrinter::setWinPageSize(int pageSize)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use QPageSize::id(windowsId) and setPageLayout(QPageSize) instead.

Sets the page size to be used by the printer under Windows to pageSize.

See also winPageSize() and pageLayout().

### int QPrinter::winPageSize() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use pageLayout.pageSize().windowsId() instead.

Returns the page size used by the printer under Windows.

See also setWinPageSize() and pageLayout().