QPageLayout 类

描述页面大小、取向及边距。 更多...

头: #include <QPageLayout>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

公共类型

enum Mode { StandardMode, FullPageMode }
enum Orientation { Portrait, Landscape }
enum Unit { Millimeter, Point, Inch, Pica, Didot, Cicero }

公共函数

QPageLayout ()
QPageLayout (const QPageSize & pageSize , QPageLayout::Orientation orientation , const QMarginsF & margins , QPageLayout::Unit units = Point, const QMarginsF & minMargins = QMarginsF(0, 0, 0, 0))
QPageLayout (const QPageLayout & other )
~QPageLayout ()
QRectF fullRect () const
QRectF fullRect (QPageLayout::Unit units ) const
QRect fullRectPixels (int resolution ) const
QRect fullRectPoints () const
bool isEquivalentTo (const QPageLayout & other ) const
bool isValid () const
QMarginsF margins () const
QMarginsF margins (QPageLayout::Unit units ) const
QMargins marginsPixels (int resolution ) const
QMargins marginsPoints () const
QMarginsF maximumMargins () const
QMarginsF minimumMargins () const
QPageLayout::Mode mode () const
QPageLayout::Orientation orientation () const
QPageSize pageSize () const
QRectF paintRect () const
QRectF paintRect (QPageLayout::Unit units ) const
QRect paintRectPixels (int resolution ) const
QRect paintRectPoints () const
bool setBottomMargin (qreal bottomMargin )
bool setLeftMargin (qreal leftMargin )
bool setMargins (const QMarginsF & margins )
void setMinimumMargins (const QMarginsF & minMargins )
void setMode (QPageLayout::Mode mode )
void setOrientation (QPageLayout::Orientation orientation )
void setPageSize (const QPageSize & pageSize , const QMarginsF & minMargins = QMarginsF(0, 0, 0, 0))
bool setRightMargin (qreal rightMargin )
bool setTopMargin (qreal topMargin )
void setUnits (QPageLayout::Unit units )
void swap (QPageLayout & other )
QPageLayout::Unit units () const
QPageLayout & operator= (QPageLayout && other )
QPageLayout & operator= (const QPageLayout & other )
bool operator!= (const QPageLayout & lhs , const QPageLayout & rhs )
bool operator== (const QPageLayout & lhs , const QPageLayout & rhs )

详细描述

The QPageLayout class defines the layout of a page in a paged document, with the page size, orientation and margins able to be set and the full page and paintable page rectangles defined by those attributes able to be queried in a variety of units.

The page size is defined by the QPageSize class which can be queried for page size attributes. Note that the QPageSize itself is always defined in a Portrait orientation.

The minimum margins can be defined for the layout but normally default to 0. When used in conjunction with Qt's printing support the minimum margins will reflect the minimum printable area defined by the printer.

In the default StandardMode the current margins and minimum margins are always taken into account. The paintable rectangle is the full page rectangle less the current margins, and the current margins can only be set to values between the minimum margins and the maximum margins allowed by the full page size.

FullPageMode the current margins and minimum margins are not taken into account. The paintable rectangle is the full page rectangle, and the current margins can be set to any values regardless of the minimum margins and page size.

另请参阅 QPageSize .

成员类型文档编制

enum QPageLayout:: Mode

定义页面布局模式

常量 描述
QPageLayout::StandardMode 0 Paint Rect includes margins, margins must fall between the minimum and maximum.
QPageLayout::FullPageMode 1 Paint Rect excludes margins, margins can be any value and must be managed manually.

enum QPageLayout:: Orientation

此枚举类型定义页面取向

常量 描述
QPageLayout::Portrait 0 The page size is used in its default orientation
QPageLayout::Landscape 1 The page size is rotated through 90 degrees

Note that some standard page sizes are defined with a width larger than their height, hence the orientation is defined relative to the standard page size and not using the relative page dimensions.

enum QPageLayout:: Unit

This enum type is used to specify the measurement unit for page layout and margins.

常量 描述
QPageLayout::Millimeter 0
QPageLayout::Point 1 1/72th of an inch
QPageLayout::Inch 2
QPageLayout::Pica 3 1/72th of a foot, 1/6th of an inch, 12 Points
QPageLayout::Didot 4 1/72th of a French inch, 0.375 mm
QPageLayout::Cicero 5 1/6th of a French inch, 12 Didot, 4.5mm

成员函数文档编制

QPageLayout:: QPageLayout ()

创建无效 QPageLayout。

QPageLayout:: QPageLayout (const QPageSize & pageSize , QPageLayout::Orientation orientation , const QMarginsF & margins , QPageLayout::Unit units = Point, const QMarginsF & minMargins = QMarginsF(0, 0, 0, 0))

Creates a QPageLayout with the given pageSize , orientation and margins 以给定 units .

Optionally define the minimum allowed margins minMargins , e.g. the minimum margins able to be printed by a physical print device.

The constructed QPageLayout will be in StandardMode .

The margins given will be clamped to the minimum margins and the maximum margins allowed by the page size.

QPageLayout:: QPageLayout (const QPageLayout & other )

拷贝构造函数,拷贝 other to this.

QPageLayout:: ~QPageLayout ()

销毁页面布局。

QRectF QPageLayout:: fullRect () const

Returns the full page rectangle in the current layout units.

The page rectangle takes into account the page size and page orientation, but not the page margins.

另请参阅 paintRect () 和 units ().

QRectF QPageLayout:: fullRect ( QPageLayout::Unit units ) const

Returns the full page rectangle in the required units .

The page rectangle takes into account the page size and page orientation, but not the page margins.

另请参阅 paintRect ().

QRect QPageLayout:: fullRectPixels ( int resolution ) const

Returns the full page rectangle in device pixels for the given resolution .

The page rectangle takes into account the page size and page orientation, but not the page margins.

另请参阅 paintRect ().

QRect QPageLayout:: fullRectPoints () const

Returns the full page rectangle in Postscript Points (1/72 of an inch).

The page rectangle takes into account the page size and page orientation, but not the page margins.

另请参阅 paintRect ().

bool QPageLayout:: isEquivalentTo (const QPageLayout & other ) const

返回 true if this page layout is equivalent to the other page layout, i.e. if the page has the same size, margins and orientation.

bool QPageLayout:: isValid () const

返回 true if this page layout is valid.

QMarginsF QPageLayout:: margins () const

Returns the margins of the page layout using the currently set units.

另请参阅 setMargins () 和 units ().

QMarginsF QPageLayout:: margins ( QPageLayout::Unit units ) const

Returns the margins of the page layout using the requested units .

另请参阅 setMargins () 和 margins ().

QMargins QPageLayout:: marginsPixels ( int resolution ) const

Returns the margins of the page layout in device pixels for the given resolution .

另请参阅 setMargins ().

QMargins QPageLayout:: marginsPoints () const

Returns the margins of the page layout in Postscript Points (1/72 of an inch).

另请参阅 setMargins () 和 margins ().

QMarginsF QPageLayout:: maximumMargins () const

Returns the maximum margins that would be applied if the page layout was in StandardMode .

The maximum margins allowed are calculated as the full size of the page minus the minimum margins set. For example, if the page width is 100 points and the minimum right margin is 10 points, then the maximum left margin will be 90 points.

另请参阅 setMinimumMargins () 和 minimumMargins ().

QMarginsF QPageLayout:: minimumMargins () const

Returns the minimum margins of the page layout.

另请参阅 setMinimumMargins () 和 maximumMargins ().

QPageLayout::Mode QPageLayout:: mode () const

Returns the page layout mode.

另请参阅 setMode ().

QPageLayout::Orientation QPageLayout:: orientation () const

Returns the page orientation of the page layout.

另请参阅 setOrientation ().

QPageSize QPageLayout:: pageSize () const

Returns the page size of the page layout.

注意, QPageSize is always defined in a Portrait orientation. To obtain a size that takes the set orientation into account you must use fullRect ().

另请参阅 setPageSize ().

QRectF QPageLayout:: paintRect () const

Returns the page rectangle in the current layout units.

The paintable rectangle takes into account the page size, orientation and margins.

FullPageMode mode is set then the fullRect () is returned and the margins must be manually managed.

QRectF QPageLayout:: paintRect ( QPageLayout::Unit units ) const

Returns the page rectangle in the required units .

The paintable rectangle takes into account the page size, orientation and margins.

FullPageMode mode is set then the fullRect () is returned and the margins must be manually managed.

QRect QPageLayout:: paintRectPixels ( int resolution ) const

Returns the paintable rectangle in rounded device pixels for the given resolution .

The paintable rectangle takes into account the page size, orientation and margins.

FullPageMode mode is set then the fullRect () is returned and the margins must be manually managed.

QRect QPageLayout:: paintRectPoints () const

Returns the paintable rectangle in rounded Postscript Points (1/72 of an inch).

The paintable rectangle takes into account the page size, orientation and margins.

FullPageMode mode is set then the fullRect () is returned and the margins must be manually managed.

bool QPageLayout:: setBottomMargin ( qreal bottomMargin )

Sets the bottom page margin of the page layout to bottomMargin . Returns true if the margin was successfully set.

The units used are those currently defined for the layout. To use different units call setUnits () first.

If in the default StandardMode then the new margin must fall between the minimum margin set and the maximum margin allowed by the page size, otherwise the margin will not be set.

If in FullPageMode then any margin values will be accepted.

另请参阅 setMargins () 和 margins ().

bool QPageLayout:: setLeftMargin ( qreal leftMargin )

Sets the left page margin of the page layout to leftMargin . Returns true if the margin was successfully set.

The units used are those currently defined for the layout. To use different units call setUnits () first.

If in the default StandardMode then the new margin must fall between the minimum margin set and the maximum margin allowed by the page size, otherwise the margin will not be set.

If in FullPageMode then any margin values will be accepted.

另请参阅 setMargins () 和 margins ().

bool QPageLayout:: setMargins (const QMarginsF & margins )

Sets the page margins of the page layout to margins Returns true if the margins were successfully set.

The units used are those currently defined for the layout. To use different units then call setUnits () first.

If in the default StandardMode then all the new margins must fall between the minimum margins set and the maximum margins allowed by the page size, otherwise the margins will not be set.

If in FullPageMode then any margin values will be accepted.

另请参阅 margins () 和 units ().

void QPageLayout:: setMinimumMargins (const QMarginsF & minMargins )

Sets the minimum page margins of the page layout to minMargins .

It is not recommended to override the default values set for a page size as this may be the minimum printable area for a physical print device.

StandardMode mode is set then the existing margins will be clamped to the new minMargins and the maximum allowed by the page size. If the FullPageMode is set then the existing margins will be unchanged.

另请参阅 minimumMargins () 和 setMargins ().

void QPageLayout:: setMode ( QPageLayout::Mode mode )

Sets a page layout mode to mode .

另请参阅 mode ().

void QPageLayout:: setOrientation ( QPageLayout::Orientation orientation )

Sets the page orientation of the page layout to orientation .

Changing the orientation does not affect the current margins or the minimum margins.

另请参阅 orientation ().

void QPageLayout:: setPageSize (const QPageSize & pageSize , const QMarginsF & minMargins = QMarginsF(0, 0, 0, 0))

Sets the page size of the page layout to pageSize .

Optionally define the minimum allowed margins minMargins , e.g. the minimum margins able to be printed by a physical print device, otherwise the minimum margins will default to 0.

StandardMode is set then the existing margins will be clamped to the new minimum margins and the maximum margins allowed by the page size. If FullPageMode is set then the existing margins will be unchanged.

另请参阅 pageSize ().

bool QPageLayout:: setRightMargin ( qreal rightMargin )

Sets the right page margin of the page layout to rightMargin . Returns true if the margin was successfully set.

The units used are those currently defined for the layout. To use different units call setUnits () first.

If in the default StandardMode then the new margin must fall between the minimum margin set and the maximum margin allowed by the page size, otherwise the margin will not be set.

If in FullPageMode then any margin values will be accepted.

另请参阅 setMargins () 和 margins ().

bool QPageLayout:: setTopMargin ( qreal topMargin )

Sets the top page margin of the page layout to topMargin . Returns true if the margin was successfully set.

The units used are those currently defined for the layout. To use different units call setUnits () first.

If in the default StandardMode then the new margin must fall between the minimum margin set and the maximum margin allowed by the page size, otherwise the margin will not be set.

If in FullPageMode then any margin values will be accepted.

另请参阅 setMargins () 和 margins ().

void QPageLayout:: setUnits ( QPageLayout::Unit units )

设置 units used to define the page layout.

另请参阅 units ().

void QPageLayout:: swap ( QPageLayout & other )

交换此页面布局与 other 。此函数非常快且从不失败。

QPageLayout::Unit QPageLayout:: units () const

Returns the units the page layout is currently defined in.

另请参阅 setUnits ().

QPageLayout &QPageLayout:: operator= ( QPageLayout && other )

移动赋值 other 到此 QPageLayout instance, transferring the ownership of the managed pointer to this instance.

QPageLayout &QPageLayout:: operator= (const QPageLayout & other )

赋值运算符,赋值 other to this.

相关非成员

bool operator!= (const QPageLayout & lhs , const QPageLayout & rhs )

返回 true if page layout lhs is not equal to page layout rhs , i.e. if any of the attributes differ.

Note that this is a strict equality, especially for page size where the QPageSize ID, name and size must exactly match, and the margins where the units must match.

另请参阅 QPageLayout::isEquivalentTo ().

bool operator== (const QPageLayout & lhs , const QPageLayout & rhs )

返回 true if page layout lhs is equal to page layout rhs , i.e. if all the attributes are exactly equal.

Note that this is a strict equality, especially for page size where the QPageSize ID, name and size must exactly match, and the margins where the units must match.

另请参阅 QPageLayout::isEquivalentTo ().