QPrintDialog Class▲
-
Header: QPrintDialog
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS PrintSupport)
target_link_libraries(mytarget PRIVATE Qt6::PrintSupport)
-
qmake: QT += printsupport
-
Inherits: QAbstractPrintDialog
-
Group: QPrintDialog is part of standard-dialogs, Printer and Printing APIs
Detailed Description▲
The dialog allows users to change document-related settings, such as the paper size and orientation, type of print (color or grayscale), range of pages, and number of copies to print.
Controls are also provided to enable users to choose from the printers available, including any configured network printers.
Typically, QPrintDialog objects are constructed with a QPrinter object, and executed using the exec() function.
QPrintDialog printDialog(printer, parent);
if
(printDialog.exec() ==
QDialog::
Accepted) {
// print ...
}
If the dialog is accepted by the user, the QPrinter object is correctly configured for printing.
The printer dialog (shown above in Plastique style) enables access to common printing properties. On X11 platforms that use the CUPS printing system, the settings for each available printer can be modified via the dialog's Properties push button.
On Windows and macOS, the native print dialog is used, which means that some QWidget and QDialog properties set on the dialog won't be respected. The native print dialog on macOS does not support setting printer options, i.e. setOptions() and setOption() have no effect.
In Qt 4.4, it was possible to use the static functions to show a sheet on macOS. This is no longer supported in Qt 4.5. If you want this functionality, use QPrintDialog::open().
See Also▲
See also QPageSetupDialog, QPrinter
Property Documentation▲
options : PrintDialogOptions▲
This property holds the various options that affect the look and feel of the dialog
By default, all options are disabled.
Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).
Access functions:
-
options() const
-
void setOptions( options)
See Also▲
See also setOption(), testOption()
Member Function Documentation▲
[explicit] QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent = nullptr)▲
Constructs a new modal printer dialog for the given printer with the given parent.
[explicit] QPrintDialog::QPrintDialog(QWidget *parent = nullptr)▲
Constructs a print dialog with the given parent.
[virtual] QPrintDialog::~QPrintDialog()▲
Destroys the print dialog.