QAbstractPrintDialog Class

The QAbstractPrintDialog class provides a base implementation for print dialogs used to configure printers. More...

Header: #include <QAbstractPrintDialog>
CMake: find_package(Qt6 REQUIRED COMPONENTS PrintSupport)
target_link_libraries(mytarget PRIVATE Qt6::PrintSupport)
qmake: QT += printsupport
Inherits: QDialog
Inherited By:


Public Types

enum PrintDialogOption { PrintToFile, PrintSelection, PrintPageRange, PrintShowPageSize, PrintCollateCopies, PrintCurrentPage }
flags PrintDialogOptions
enum PrintRange { AllPages, Selection, PageRange, CurrentPage }

Public Functions

QAbstractPrintDialog(QPrinter *printer, QWidget *parent = nullptr)
int fromPage() const
int maxPage() const
int minPage() const
QAbstractPrintDialog::PrintRange printRange() const
QPrinter *printer() const
void setFromTo(int from, int to)
void setMinMax(int min, int max)
void setOptionTabs(const QList<QWidget *> &tabs)
void setPrintRange(QAbstractPrintDialog::PrintRange range)
int toPage() const

Detailed Description

This class implements getter and setter functions that are used to customize settings shown in print dialogs, but it is not used directly. Use QPrintDialog to display a print dialog in your application.

See also QPrintDialog and QPrinter.

Member Type Documentation

enum QAbstractPrintDialog::PrintDialogOption
flags QAbstractPrintDialog::PrintDialogOptions

Used to specify which parts of the print dialog should be visible.

QAbstractPrintDialog::PrintToFile0x0001The print to file option is enabled.
QAbstractPrintDialog::PrintSelection0x0002The print selection option is enabled.
QAbstractPrintDialog::PrintPageRange0x0004The page range selection option is enabled.
QAbstractPrintDialog::PrintShowPageSize0x0008Show the page size + margins page only if this is enabled.
QAbstractPrintDialog::PrintCollateCopies0x0010The collate copies option is enabled
QAbstractPrintDialog::PrintCurrentPage0x0040The print current page option is enabled

The PrintDialogOptions type is a typedef for QFlags<PrintDialogOption>. It stores an OR combination of PrintDialogOption values.

enum QAbstractPrintDialog::PrintRange

Used to specify the print range selection option.

QAbstractPrintDialog::AllPages0All pages should be printed.
QAbstractPrintDialog::Selection1Only the selection should be printed.
QAbstractPrintDialog::PageRange2The specified page range should be printed.
QAbstractPrintDialog::CurrentPage3Only the currently visible page should be printed.

See also QPrinter::PrintRange.

Member Function Documentation

[explicit] QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent = nullptr)

Constructs an abstract print dialog for printer with parent as parent widget.

int QAbstractPrintDialog::fromPage() const

Returns the first page to be printed By default, this value is set to 0.

int QAbstractPrintDialog::maxPage() const

Returns the maximum page in the page range. As of Qt 4.4, this function returns INT_MAX by default. Previous versions returned 1 by default.

int QAbstractPrintDialog::minPage() const

Returns the minimum page in the page range. By default, this value is set to 1.

QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const

Returns the print range.

See also setPrintRange().

QPrinter *QAbstractPrintDialog::printer() const

Returns the printer that this printer dialog operates on.

void QAbstractPrintDialog::setFromTo(int from, int to)

Sets the range in the print dialog to be from from to to.

void QAbstractPrintDialog::setMinMax(int min, int max)

Sets the page range in this dialog to be from min to max. This also enables the PrintPageRange option.

void QAbstractPrintDialog::setOptionTabs(const QList<QWidget *> &tabs)

Set a list of widgets as tabs to be shown on the print dialog, if supported.

Currently this option is only supported on X11.

Setting the option tabs will transfer their ownership to the print dialog.

void QAbstractPrintDialog::setPrintRange(QAbstractPrintDialog::PrintRange range)

Sets the print range option in to be range.

See also printRange().

int QAbstractPrintDialog::toPage() const

Returns the last page to be printed. By default, this value is set to 0.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.