- class QPageLayout¶
Describes the size, orientation and margins of a page. More…
Synopsis¶
Methods¶
def
__init__()
def
fullRect()
def
fullRectPixels()
def
fullRectPoints()
def
isEquivalentTo()
def
isValid()
def
margins()
def
marginsPixels()
def
marginsPoints()
def
maximumMargins()
def
minimumMargins()
def
mode()
def
__ne__()
def
__eq__()
def
orientation()
def
pageSize()
def
paintRect()
def
setLeftMargin()
def
setMargins()
def
setMode()
def
setOrientation()
def
setPageSize()
def
setRightMargin()
def
setTopMargin()
def
setUnits()
def
swap()
def
units()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
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 theQPageSize
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.In
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.See also
- class Unit¶
This enum type is used to specify the measurement unit for page layout and margins.
Constant
Description
QPageLayout.Millimeter
QPageLayout.Point
1/72th of an inch
QPageLayout.Inch
QPageLayout.Pica
1/72th of a foot, 1/6th of an inch, 12 Points
QPageLayout.Didot
1/72th of a French inch, 0.375 mm
QPageLayout.Cicero
1/6th of a French inch, 12 Didot, 4.5mm
- class Orientation¶
This enum type defines the page orientation
Constant
Description
QPageLayout.Portrait
The page size is used in its default orientation
QPageLayout.Landscape
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.
- class Mode¶
Defines the page layout mode
Constant
Description
QPageLayout.StandardMode
Paint Rect includes margins, margins must fall between the minimum and maximum.
QPageLayout.FullPageMode
Paint Rect excludes margins, margins can be any value and must be managed manually.
In StandardMode, when setting margins, use
Clamp
to automatically clamp the margins to fall between the minimum and maximum allowed values.See also
- class OutOfBoundsPolicy¶
Defines the policy for margins that are out of bounds
Constant
Description
QPageLayout.OutOfBoundsPolicy.Reject
The margins must fall within the minimum and maximum values, otherwise they will be rejected.
QPageLayout.OutOfBoundsPolicy.Clamp
The margins are clamped between the minimum and maximum values to ensure they are valid.
Note
The policy has no effect in
FullPageMode
, where all margins are accepted.Added in version 6.8.
- __init__()¶
Creates an invalid
QPageLayout
.- __init__(other)
- Parameters:
other –
QPageLayout
Copy constructor, copies
other
to this.- __init__(pageSize, orientation, margins[, units=QPageLayout.Unit.Point[, minMargins=QMarginsF(0, 0, 0, 0)]])
- Parameters:
pageSize –
QPageSize
orientation –
Orientation
margins –
QMarginsF
units –
Unit
minMargins –
QMarginsF
Creates a
QPageLayout
with the givenpageSize
,orientation
andmargins
in the givenunits
.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 inStandardMode
.The
margins
given will be clamped to the minimum margins and the maximum margins allowed by the page size.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.
See also
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.
See also
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.
See also
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.
See also
- isEquivalentTo(other)¶
- Parameters:
other –
QPageLayout
- Return type:
bool
Returns
true
if this page layout is equivalent to theother
page layout, i.e. if the page has the same size, margins and orientation.- isValid()¶
- Return type:
bool
Returns
true
if this page layout is valid.Returns the margins of the page layout using the currently set units.
See also
Returns the margins of the page layout using the requested
units
.See also
Returns the margins of the page layout in device pixels for the given
resolution
.See also
Returns the margins of the page layout in Postscript Points (1/72 of an inch).
See also
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.
See also
Returns the minimum margins of the page layout.
See also
Returns the page layout mode.
See also
- __ne__(rhs)¶
- Parameters:
rhs –
QPageLayout
- Return type:
bool
Returns
true
if page layoutlhs
is not equal to page layoutrhs
, 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.See also
- __eq__(rhs)¶
- Parameters:
rhs –
QPageLayout
- Return type:
bool
Returns
true
if page layoutlhs
is equal to page layoutrhs
, 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.See also
- orientation()¶
- Return type:
Returns the page orientation of the page layout.
See also
Returns the page size of the page layout.
Note that the
QPageSize
is always defined in a Portrait orientation. To obtain a size that takes the set orientation into account you must usefullRect()
.See also
Returns the page rectangle in the current layout units.
The paintable rectangle takes into account the page size, orientation and margins.
If the
FullPageMode
mode is set then thefullRect()
is returned and the margins must be manually managed.Returns the page rectangle in the required
units
.The paintable rectangle takes into account the page size, orientation and margins.
If the
FullPageMode
mode is set then thefullRect()
is returned and the margins must be manually managed.Returns the paintable rectangle in rounded device pixels for the given
resolution
.The paintable rectangle takes into account the page size, orientation and margins.
If the
FullPageMode
mode is set then thefullRect()
is returned and the margins must be manually managed.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.
If the
FullPageMode
mode is set then thefullRect()
is returned and the margins must be manually managed.- setBottomMargin(bottomMargin[, outOfBoundsPolicy=QPageLayout.OutOfBoundsPolicy.Reject])¶
- Parameters:
bottomMargin – float
outOfBoundsPolicy –
OutOfBoundsPolicy
- Return type:
bool
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.Since Qt 6.8, the optional
outOfBoundsPolicy
can be used to specify how margins that are out of bounds are handled.See also
- setLeftMargin(leftMargin[, outOfBoundsPolicy=QPageLayout.OutOfBoundsPolicy.Reject])¶
- Parameters:
leftMargin – float
outOfBoundsPolicy –
OutOfBoundsPolicy
- Return type:
bool
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.Since Qt 6.8, the optional
outOfBoundsPolicy
can be used to specify how margins that are out of bounds are handled.See also
- setMargins(margins[, outOfBoundsPolicy=QPageLayout.OutOfBoundsPolicy.Reject])¶
- Parameters:
margins –
QMarginsF
outOfBoundsPolicy –
OutOfBoundsPolicy
- Return type:
bool
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.Since Qt 6.8, the optional
outOfBoundsPolicy
can be used to specify how margins that are out of bounds are handled.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.
If the
StandardMode
mode is set then the existing margins will be clamped to the newminMargins
and the maximum allowed by the page size. If theFullPageMode
is set then the existing margins will be unchanged.See also
Sets a page layout mode to
mode
.See also
- setOrientation(orientation)¶
- Parameters:
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.
See also
- setPageSize(pageSize[, 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.If
StandardMode
is set then the existing margins will be clamped to the new minimum margins and the maximum margins allowed by the page size. IfFullPageMode
is set then the existing margins will be unchanged.See also
- setRightMargin(rightMargin[, outOfBoundsPolicy=QPageLayout.OutOfBoundsPolicy.Reject])¶
- Parameters:
rightMargin – float
outOfBoundsPolicy –
OutOfBoundsPolicy
- Return type:
bool
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.Since Qt 6.8, the optional
outOfBoundsPolicy
can be used to specify how margins that are out of bounds are handled.See also
- setTopMargin(topMargin[, outOfBoundsPolicy=QPageLayout.OutOfBoundsPolicy.Reject])¶
- Parameters:
topMargin – float
outOfBoundsPolicy –
OutOfBoundsPolicy
- Return type:
bool
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.Since Qt 6.8, the optional
outOfBoundsPolicy
can be used to specify how margins that are out of bounds are handled.See also
Sets the
units
used to define the page layout.See also
- swap(other)¶
- Parameters:
other –
QPageLayout
Swaps this page layout with
other
. This function is very fast and never fails.Returns the units the page layout is currently defined in.
See also