QAbstractPrintDialog Class

QAbstractPrintDialog 类为用于配置打印机的打印对话框提供了基本实现。更多

头文件: #include <QAbstractPrintDialog>
CMake.QAbstractPrintDialog find_package(Qt6 REQUIRED COMPONENTS PrintSupport)
target_link_libraries(mytarget PRIVATE Qt6::PrintSupport)
qmake: QT += printsupport
继承: QDialog
继承于:

QPrintDialog

公共类型

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

公共函数

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

详细说明

该类实现了用于自定义打印对话框中显示的设置的 getter 和 setter 函数,但不会被直接使用。请使用QPrintDialog 在应用程序中显示打印对话框。

另请参阅 QPrintDialogQPrinter

成员类型文档

enum QAbstractPrintDialog::PrintDialogOption
flags QAbstractPrintDialog::PrintDialogOptions

用于指定打印对话框的哪些部分应该可见。

常量说明
QAbstractPrintDialog::PrintToFile0x0001打印到文件选项已启用。
QAbstractPrintDialog::PrintSelection0x0002打印选择选项已启用。
QAbstractPrintDialog::PrintPageRange0x0004页面范围选择选项已启用。
QAbstractPrintDialog::PrintShowPageSize0x0008仅在启用该选项时才显示页面大小 + 页边距页面。
QAbstractPrintDialog::PrintCollateCopies0x0010整理副本选项已启用
QAbstractPrintDialog::PrintCurrentPage0x0040打印当前页选项已启用

PrintDialogOptions 类型是QFlags<PrintDialogOption> 的类型定义。它存储打印对话框选项值的 OR 组合。

enum QAbstractPrintDialog::PrintRange

用于指定打印范围选择选项。

常数说明
QAbstractPrintDialog::AllPages0应打印所有页面。
QAbstractPrintDialog::Selection1只打印选择的页面。
QAbstractPrintDialog::PageRange2打印指定的页面范围。
QAbstractPrintDialog::CurrentPage3只打印当前可见页面。

另请参阅 QPrinter::PrintRange

成员函数文档

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

printer 构建一个抽象打印对话框,parent 为父窗口部件。

int QAbstractPrintDialog::fromPage() const

返回要打印的第一页 默认情况下,该值设置为 0。

int QAbstractPrintDialog::maxPage() const

返回页面范围中的最大页面。从 Qt 4.4 开始,该函数默认返回 INT_MAX。以前的版本默认返回 1。

int QAbstractPrintDialog::minPage() const

返回页面范围内的最小页面。默认情况下,该值设置为 1。

QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const

返回打印范围。

另请参阅 setPrintRange()。

QPrinter *QAbstractPrintDialog::printer() const

返回此打印机对话框所使用的打印机。

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

将打印对话框中的范围设置为fromto

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

将此对话框中的页面范围设置为从minmax 。这也会启用PrintPageRange 选项。

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

如果支持,将部件列表设置为tabs ,以便在打印对话框中显示。

目前该选项仅支持 X11。

设置选项卡将把它们的所有权转移到打印对话框。

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

将打印范围选项设置为range

另请参阅 printRange() 。

int QAbstractPrintDialog::toPage() const

返回最后打印的页面。默认情况下,该值设置为 0。

© 2025 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.