QPrintDialog 類

QPrintDialog 類提供用於指定打印機配置的對話框。 更多...

頭: #include <QPrintDialog>
qmake: QT += printsupport
繼承: QAbstractPrintDialog

特性

公共函數

QPrintDialog (QPrinter * printer , QWidget * parent = nullptr)
virtual ~QPrintDialog ()
void open (QObject * receiver , const char * member )
QAbstractPrintDialog::PrintDialogOptions options () const
QPrinter * printer ()
void setOption (QAbstractPrintDialog::PrintDialogOption option , bool on = true)
void setOptions (QAbstractPrintDialog::PrintDialogOptions options )
bool testOption (QAbstractPrintDialog::PrintDialogOption option ) const

重實現公共函數

virtual void done (int result ) override
virtual int exec () override
virtual void setVisible (bool visible ) override

信號

void accepted (QPrinter * printer )

詳細描述

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 () 函數。

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 特性 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 () 和 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 ().

另請參閱 QPageSetupDialog and QPrinter .

特性文檔編製

options : PrintDialogOptions

This property holds the various options that affect the look and feel of the dialog

默認情況下,所有選項是被禁用的。

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

該特性在 Qt 4.5 引入。

訪問函數:

QAbstractPrintDialog::PrintDialogOptions options () const
void setOptions (QAbstractPrintDialog::PrintDialogOptions options )

另請參閱 setOption () 和 testOption ().

成員函數文檔編製

QPrintDialog:: QPrintDialog ( QPrinter * printer , QWidget * parent = nullptr)

Constructs a new modal printer dialog for the given printer 采用給定 parent .

[signal] void QPrintDialog:: accepted ( QPrinter * printer )

This signal is emitted when the user accepts the values set in the print dialog. The printer parameter includes the printer that the settings were applied to.

[虛擬] QPrintDialog:: ~QPrintDialog ()

Destroys the print dialog.

[override virtual] void QPrintDialog:: done ( int result )

重實現: QDialog::done (int r).

關閉對話框並將其結果代碼設為 result 。若此對話框的展示是采用 exec (),done() 導緻本地事件循環的完成,且 exec () 返迴 result .

注意: This function does not apply to the Native Print Dialog on the Mac macOS and Windows platforms, because the dialog is required to be modal and only the user can close it.

另請參閱 QDialog::done ().

[override virtual] int QPrintDialog:: exec ()

重實現: QDialog::exec ().

void QPrintDialog:: open ( QObject * receiver , const char * member )

這是重載函數。

打開對話框並連接其 accepted () 信號到槽,指定通過 receiver and member .

將從槽斷開信號連接,當關閉對話框時。

該函數在 Qt 4.5 引入。

QPrinter *QPrintDialog:: printer ()

Returns the printer that this printer dialog operates on. This can be useful when using the QPrintDialog::open () 方法。

void QPrintDialog:: setOption ( QAbstractPrintDialog::PrintDialogOption option , bool on = true)

設置給定 option 為被啓用若 on 為 true;否則,清零給定 option .

另請參閱 options and testOption ().

[override virtual] void QPrintDialog:: setVisible ( bool visible )

重實現: QDialog::setVisible (bool visible).

bool QPrintDialog:: testOption ( QAbstractPrintDialog::PrintDialogOption option ) const

返迴 true 若給定 option 被啓用;否則,返迴 false。

另請參閱 options and setOption ().