![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtGui More...
#include <qpagelayout.h>
Public Types | |
enum | Unit { Millimeter , Point , Inch , Pica , Didot , Cicero } |
This enum type is used to specify the measurement unit for page layout and margins. More... | |
enum | Orientation { Portrait , Landscape } |
This enum type defines the page orientation. More... | |
enum | Mode { StandardMode , FullPageMode } |
Defines the page layout mode. More... | |
enum class | OutOfBoundsPolicy { Reject , Clamp } |
Public Member Functions | |
QPageLayout () | |
Creates an invalid QPageLayout. | |
QPageLayout (const QPageSize &pageSize, Orientation orientation, const QMarginsF &margins, Unit units=Point, const QMarginsF &minMargins=QMarginsF(0, 0, 0, 0)) | |
Creates a QPageLayout with the given pageSize, orientation and margins in the given units. | |
QPageLayout (const QPageLayout &other) | |
Copy constructor, copies other to this. | |
QPageLayout & | operator= (const QPageLayout &other) |
Assignment operator, assigns other to this. | |
~QPageLayout () | |
Destroys the page layout. | |
void | swap (QPageLayout &other) noexcept |
\memberswap{page layout} | |
bool | isEquivalentTo (const QPageLayout &other) const |
Returns true if this page layout is equivalent to the other page layout, i.e. | |
bool | isValid () const |
Returns true if this page layout is valid. | |
void | setMode (Mode mode) |
Sets a page layout mode to mode. | |
Mode | mode () const |
Returns the page layout mode. | |
void | setPageSize (const QPageSize &pageSize, const QMarginsF &minMargins=QMarginsF(0, 0, 0, 0)) |
Sets the page size of the page layout to pageSize. | |
QPageSize | pageSize () const |
Returns the page size of the page layout. | |
void | setOrientation (Orientation orientation) |
Sets the page orientation of the page layout to orientation. | |
Orientation | orientation () const |
Returns the page orientation of the page layout. | |
void | setUnits (Unit units) |
Sets the units used to define the page layout. | |
Unit | units () const |
Returns the units the page layout is currently defined in. | |
bool | setMargins (const QMarginsF &margins, OutOfBoundsPolicy outOfBoundsPolicy=OutOfBoundsPolicy::Reject) |
Sets the page margins of the page layout to margins. | |
bool | setLeftMargin (qreal leftMargin, OutOfBoundsPolicy outOfBoundsPolicy=OutOfBoundsPolicy::Reject) |
Sets the left page margin of the page layout to leftMargin. | |
bool | setRightMargin (qreal rightMargin, OutOfBoundsPolicy outOfBoundsPolicy=OutOfBoundsPolicy::Reject) |
Sets the right page margin of the page layout to rightMargin. | |
bool | setTopMargin (qreal topMargin, OutOfBoundsPolicy outOfBoundsPolicy=OutOfBoundsPolicy::Reject) |
Sets the top page margin of the page layout to topMargin. | |
bool | setBottomMargin (qreal bottomMargin, OutOfBoundsPolicy outOfBoundsPolicy=OutOfBoundsPolicy::Reject) |
Sets the bottom page margin of the page layout to bottomMargin. | |
QMarginsF | margins () const |
Returns the margins of the page layout using the currently set units. | |
QMarginsF | margins (Unit units) const |
Returns the margins of the page layout using the requested units. | |
QMargins | marginsPoints () const |
Returns the margins of the page layout in Postscript Points (1/72 of an inch). | |
QMargins | marginsPixels (int resolution) const |
Returns the margins of the page layout in device pixels for the given resolution. | |
void | setMinimumMargins (const QMarginsF &minMargins) |
Sets the minimum page margins of the page layout to minMargins. | |
QMarginsF | minimumMargins () const |
Returns the minimum margins of the page layout. | |
QMarginsF | maximumMargins () const |
Returns the maximum margins that would be applied if the page layout was in StandardMode. | |
QRectF | fullRect () const |
Returns the full page rectangle in the current layout units. | |
QRectF | fullRect (Unit units) const |
Returns the full page rectangle in the required units. | |
QRect | fullRectPoints () const |
Returns the full page rectangle in Postscript Points (1/72 of an inch). | |
QRect | fullRectPixels (int resolution) const |
Returns the full page rectangle in device pixels for the given resolution. | |
QRectF | paintRect () const |
Returns the page rectangle in the current layout units. | |
QRectF | paintRect (Unit units) const |
Returns the page rectangle in the required units. | |
QRect | paintRectPoints () const |
Returns the paintable rectangle in rounded Postscript Points (1/72 of an inch). | |
QRect | paintRectPixels (int resolution) const |
Returns the paintable rectangle in rounded device pixels for the given resolution. | |
Friends | |
class | QPageLayoutPrivate |
bool | operator== (const QPageLayout &lhs, const QPageLayout &rhs) |
Returns true if page layout lhs is equal to page layout rhs, i.e. | |
bool | operator!= (const QPageLayout &lhs, const QPageLayout &rhs) |
Returns true if page layout lhs is not equal to page layout rhs, i.e. | |
\inmodule QtGui
Describes the size, orientation and margins of a page.
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.
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.
Definition at line 19 of file qpagelayout.h.
enum QPageLayout::Mode |
Defines the page layout mode.
\value StandardMode Paint Rect includes margins, margins must fall between the minimum and maximum. \value FullPageMode Paint Rect excludes margins, margins can be any value and must be managed manually.
In StandardMode, when setting margins, use \l{QPageLayout::OutOfBoundsPolicy::}{Clamp} to automatically clamp the margins to fall between the minimum and maximum allowed values.
Enumerator | |
---|---|
StandardMode | |
FullPageMode |
Definition at line 38 of file qpagelayout.h.
This enum type defines the page orientation.
\value Portrait The page size is used in its default orientation \value 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.
Enumerator | |
---|---|
Portrait | |
Landscape |
Definition at line 33 of file qpagelayout.h.
|
strong |
Defines the policy for margins that are out of bounds
\value Reject The margins must fall within the minimum and maximum values, otherwise they will be rejected. \value Clamp The margins are clamped between the minimum and maximum values to ensure they are valid.
Enumerator | |
---|---|
Reject | |
Clamp |
Definition at line 43 of file qpagelayout.h.
enum QPageLayout::Unit |
This enum type is used to specify the measurement unit for page layout and margins.
\value Millimeter \value Point 1/72th of an inch \value Inch \value Pica 1/72th of a foot, 1/6th of an inch, 12 Points \value Didot 1/72th of a French inch, 0.375 mm \value Cicero 1/6th of a French inch, 12 Didot, 4.5mm
Enumerator | |
---|---|
Millimeter | |
Point | |
Inch | |
Pica | |
Didot | |
Cicero |
Definition at line 24 of file qpagelayout.h.
QPageLayout::QPageLayout | ( | ) |
Creates an invalid QPageLayout.
Definition at line 313 of file qpagelayout.cpp.
QPageLayout::QPageLayout | ( | const QPageSize & | pageSize, |
Orientation | orientation, | ||
const QMarginsF & | margins, | ||
Unit | units = Point, | ||
const QMarginsF & | minMargins = QMarginsF(0, 0, 0, 0) ) |
Creates a QPageLayout with the given pageSize, orientation and margins in the given 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.
Definition at line 331 of file qpagelayout.cpp.
QPageLayout::QPageLayout | ( | const QPageLayout & | other | ) |
Copy constructor, copies other to this.
Definition at line 342 of file qpagelayout.cpp.
QPageLayout::~QPageLayout | ( | ) |
Destroys the page layout.
Definition at line 351 of file qpagelayout.cpp.
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.
Definition at line 815 of file qpagelayout.cpp.
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.
Definition at line 829 of file qpagelayout.cpp.
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.
Definition at line 857 of file qpagelayout.cpp.
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.
Definition at line 843 of file qpagelayout.cpp.
bool QPageLayout::isEquivalentTo | ( | const QPageLayout & | other | ) | const |
Returns true
if this page layout is equivalent to the other page layout, i.e.
if the page has the same size, margins and orientation.
Definition at line 417 of file qpagelayout.cpp.
bool QPageLayout::isValid | ( | ) | const |
Returns true
if this page layout is valid.
Definition at line 426 of file qpagelayout.cpp.
QMarginsF QPageLayout::margins | ( | ) | const |
Returns the margins of the page layout using the currently set units.
Definition at line 721 of file qpagelayout.cpp.
Returns the margins of the page layout using the requested units.
Definition at line 732 of file qpagelayout.cpp.
QMargins QPageLayout::marginsPixels | ( | int | resolution | ) | const |
Returns the margins of the page layout in device pixels for the given resolution.
Definition at line 754 of file qpagelayout.cpp.
QMargins QPageLayout::marginsPoints | ( | ) | const |
Returns the margins of the page layout in Postscript Points (1/72 of an inch).
Definition at line 743 of file qpagelayout.cpp.
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.
Definition at line 801 of file qpagelayout.cpp.
QMarginsF QPageLayout::minimumMargins | ( | ) | const |
Returns the minimum margins of the page layout.
Definition at line 784 of file qpagelayout.cpp.
QPageLayout::Mode QPageLayout::mode | ( | ) | const |
Returns the page layout mode.
Definition at line 445 of file qpagelayout.cpp.
QPageLayout & QPageLayout::operator= | ( | const QPageLayout & | other | ) |
Assignment operator, assigns other to this.
Move-assigns other to this QPageLayout instance, transferring the ownership of the managed pointer to this instance.
Definition at line 359 of file qpagelayout.cpp.
QPageLayout::Orientation QPageLayout::orientation | ( | ) | const |
Returns the page orientation of the page layout.
Definition at line 511 of file qpagelayout.cpp.
QPageSize QPageLayout::pageSize | ( | ) | const |
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 use fullRect().
Definition at line 480 of file qpagelayout.cpp.
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.
If the FullPageMode mode is set then the fullRect() is returned and the margins must be manually managed.
Definition at line 872 of file qpagelayout.cpp.
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 the fullRect() is returned and the margins must be manually managed.
Definition at line 887 of file qpagelayout.cpp.
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.
If the FullPageMode mode is set then the fullRect() is returned and the margins must be manually managed.
Definition at line 925 of file qpagelayout.cpp.
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.
If the FullPageMode mode is set then the fullRect() is returned and the margins must be manually managed.
Definition at line 907 of file qpagelayout.cpp.
bool QPageLayout::setBottomMargin | ( | qreal | bottomMargin, |
OutOfBoundsPolicy | outOfBoundsPolicy = OutOfBoundsPolicy::Reject ) |
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.
Definition at line 697 of file qpagelayout.cpp.
bool QPageLayout::setLeftMargin | ( | qreal | leftMargin, |
OutOfBoundsPolicy | outOfBoundsPolicy = OutOfBoundsPolicy::Reject ) |
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.
Definition at line 604 of file qpagelayout.cpp.
bool QPageLayout::setMargins | ( | const QMarginsF & | margins, |
OutOfBoundsPolicy | outOfBoundsPolicy = OutOfBoundsPolicy::Reject ) |
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.
Definition at line 554 of file qpagelayout.cpp.
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 new minMargins and the maximum allowed by the page size. If the FullPageMode is set then the existing margins will be unchanged.
Definition at line 772 of file qpagelayout.cpp.
Sets a page layout mode to mode.
Definition at line 435 of file qpagelayout.cpp.
void QPageLayout::setOrientation | ( | 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.
Definition at line 492 of file qpagelayout.cpp.
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.
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. If FullPageMode is set then the existing margins will be unchanged.
Definition at line 462 of file qpagelayout.cpp.
bool QPageLayout::setRightMargin | ( | qreal | rightMargin, |
OutOfBoundsPolicy | outOfBoundsPolicy = OutOfBoundsPolicy::Reject ) |
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.
Definition at line 635 of file qpagelayout.cpp.
bool QPageLayout::setTopMargin | ( | qreal | topMargin, |
OutOfBoundsPolicy | outOfBoundsPolicy = OutOfBoundsPolicy::Reject ) |
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.
Definition at line 666 of file qpagelayout.cpp.
Sets the units used to define the page layout.
Definition at line 520 of file qpagelayout.cpp.
|
inlinenoexcept |
\memberswap{page layout}
Definition at line 57 of file qpagelayout.h.
QPageLayout::Unit QPageLayout::units | ( | ) | const |
Returns the units the page layout is currently defined in.
Definition at line 536 of file qpagelayout.cpp.
|
friend |
Returns 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.
Definition at line 115 of file qpagelayout.h.
|
friend |
Returns 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.
Definition at line 113 of file qpagelayout.h.
|
friend |
Definition at line 110 of file qpagelayout.h.