Compatibility Members for QPrinter

以下成员源于类 QPrinter are part of the Qt compatibility layer. We advise against using them in new code.

公共类型

enum PrinterOption { PrintToFile, PrintSelection, PrintPageRange }

公共函数

bool aborted ()
bool collateCopiesEnabled () const
bool isOptionEnabled (PrinterOption option ) const
void margins (uint * top , uint * left , uint * bottom , uint * right ) const
QSize margins () const
int maxPage () const
int minPage () const
bool outputToFile () const
bool pageSetup (QWidget * parent = 0)
bool printSetup (QWidget * parent = 0)
void setCollateCopiesEnabled (bool enable )
void setMinMax (int minPage , int maxPage )
void setOptionEnabled (PrinterOption option , bool enable )
void setOutputToFile (bool enable )
bool setup (QWidget * parent = 0)

成员类型文档编制

enum QPrinter:: PrinterOption

使用 QAbstractPrintDialog::PrintDialogOption 代替。

常量
QPrinter::PrintToFile 0
QPrinter::PrintSelection 1
QPrinter::PrintPageRange 2

成员函数文档编制

bool QPrinter:: aborted ()

使用 printerState () == QPrinter::Aborted 代替。

bool QPrinter:: collateCopiesEnabled () const

Returns true if the printer is set up to collate copies of printed documents; otherwise returns false.

Use QPrintDialog::isOptionEnabled( QPrintDialog::PrintCollateCopies ) 代替。

另请参阅 setCollateCopiesEnabled () 和 collateCopies ().

bool QPrinter:: isOptionEnabled ( PrinterOption option ) const

使用 QPrintDialog 代替。

void QPrinter:: margins ( uint * top , uint * left , uint * bottom , uint * right ) const

Sets * top , * left , * bottom , * right to be the top, left, bottom, and right margins.

This function has been superseded by paperRect () 和 pageRect ()。使用 paperRect ().top() - pageRect ().top() for the top margin, paperRect (). left () - pageRect (). left () for the left margin, paperRect ().bottom() - pageRect ().bottom() for the bottom margin, and papaerRect(). right () - pageRect (). right () for the right margin.

例如,若有代码像

uint rightMargin;
uint bottomMargin;
printer->margins(0, 0, &bottomMargin, &rightMargin);
					

可以把它重写成

int rightMargin = printer->paperRect().right() - printer->pageRect().right();
int bottomMargin = printer->paperRect().bottom() - printer->pageRect().bottom();
					

QSize QPrinter:: margins () const

这是重载函数。

返回 QSize containing the left margin and the top margin.

This function has been superseded by paperRect () 和 pageRect ()。使用 paperRect (). left () - pageRect (). left () for the left margin, and paperRect ().top() - pageRect ().top() for the top margin.

例如,若有代码像

QSize margins = printer->margins();
int leftMargin = margins.width();
int topMargin = margins.height();
					

可以把它重写成

int leftMargin = printer->paperRect().left() - printer->pageRect().left();
int topMargin = printer->paperRect().top() - printer->pageRect().top();
					

int QPrinter:: maxPage () const

使用 QPrintDialog::maxPage () 代替。

int QPrinter:: minPage () const

使用 QPrintDialog::minPage () 代替。

bool QPrinter:: outputToFile () const

Returns true if the output should be written to a file, or false if the output should be sent directly to the printer. The default setting is false.

另请参阅 setOutputToFile () 和 setOutputFileName ().

bool QPrinter:: pageSetup ( QWidget * parent = 0)

Executes a page setup dialog so that the user can configure the type of page used for printing. Returns true if the contents of the dialog are accepted; returns false if the dialog is canceled.

bool QPrinter:: printSetup ( QWidget * parent = 0)

Executes a print setup dialog so that the user can configure the printing process. Returns true if the contents of the dialog are accepted; returns false if the dialog is canceled.

void QPrinter:: setCollateCopiesEnabled ( bool enable )

使用 QPrintDialog::setOption ( QPrintDialog::PrintCollateCopies ) 或 QPrintDialog::setOptions ( QPrintDialog::options () & ~ QPrintDialog::PrintCollateCopies ) instead, depending on enable .

另请参阅 collateCopiesEnabled ().

void QPrinter:: setMinMax ( int minPage , int maxPage )

使用 QPrintDialog::setMinMax () 代替。

void QPrinter:: setOptionEnabled ( PrinterOption option , bool enable )

使用 QPrintDialog 代替。

另请参阅 isOptionEnabled ().

void QPrinter:: setOutputToFile ( bool enable )

Specifies whether the output should be written to a file or sent directly to the printer.

Will output to a file if enable is true, or will output directly to the printer if enable 为 false。

另请参阅 outputToFile () 和 setOutputFileName ().

bool QPrinter:: setup ( QWidget * parent = 0)

使用 QPrintDialog 代替。

例如,若有代码像

if (printer->setup(parent))
    ...
					

可以把它重写成

QPrintDialog dialog(printer, parent);
if (dialog.exec())
    ...