![]() |
Qt 6.x
The Qt SDK
|
\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... | |
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 |
Swaps this page layout with other. | |
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) |
Sets the page margins of the page layout to margins Returns true if the margins were successfully set. | |
bool | setLeftMargin (qreal leftMargin) |
Sets the left page margin of the page layout to leftMargin. | |
bool | setRightMargin (qreal rightMargin) |
Sets the right page margin of the page layout to rightMargin. | |
bool | setTopMargin (qreal topMargin) |
Sets the top page margin of the page layout to topMargin. | |
bool | setBottomMargin (qreal bottomMargin) |
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.
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.
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 319 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 337 of file qpagelayout.cpp.
QPageLayout::QPageLayout | ( | const QPageLayout & | other | ) |
Copy constructor, copies other to this.
Definition at line 348 of file qpagelayout.cpp.
QPageLayout::~QPageLayout | ( | ) |
Destroys the page layout.
Definition at line 357 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 794 of file qpagelayout.cpp.
References QPageLayoutPrivate::fullRect(), and isValid().
Referenced by QPrinter::paperRect().
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 808 of file qpagelayout.cpp.
References QPageLayoutPrivate::fullRect(), and isValid().
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 836 of file qpagelayout.cpp.
References QPageLayoutPrivate::fullRectPixels(), and isValid().
Referenced by QMacPrintEnginePrivate::newPage_helper(), QPrinter::paperRect(), QPrintPreviewWidgetPrivate::populateScene(), and QWin32PrintEnginePrivate::updateMetrics().
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 822 of file qpagelayout.cpp.
References QPageLayoutPrivate::fullRectPoints(), and isValid().
Referenced by QPdfEnginePrivate::newPage(), QPdfEnginePrivate::pageMatrix(), and QPagePreview::paintEvent().
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 425 of file qpagelayout.cpp.
References QPageLayoutPrivate::isEquivalentTo(), and other().
Referenced by QPdfPagedPaintDevicePrivate::setPageLayout(), and QPrinterPagedPaintDevicePrivate::setPageLayout().
bool QPageLayout::isValid | ( | ) | const |
Returns true
if this page layout is valid.
Definition at line 434 of file qpagelayout.cpp.
References QPageLayoutPrivate::isValid().
Referenced by fullRect(), fullRect(), fullRectPixels(), fullRectPoints(), paintRect(), paintRect(), paintRectPixels(), paintRectPoints(), QMacPrintEngine::setProperty(), QCupsPrintEngine::setProperty(), QPdfPrintEngine::setProperty(), and QWin32PrintEngine::setProperty().
QMarginsF QPageLayout::margins | ( | ) | const |
Returns the margins of the page layout using the currently set units.
Definition at line 700 of file qpagelayout.cpp.
Referenced by operator<<(), QPagePreview::paintEvent(), QTextDocument::print(), setMargins(), QPdfPagedPaintDevicePrivate::setPageMargins(), QPrinterPagedPaintDevicePrivate::setPageMargins(), QMacPrintEngine::setProperty(), QWin32PrintEngine::setProperty(), and QWin32PrintEnginePrivate::updateMetrics().
Returns the margins of the page layout using the requested units.
Definition at line 711 of file qpagelayout.cpp.
References QPageLayoutPrivate::margins().
QMargins QPageLayout::marginsPixels | ( | int | resolution | ) | const |
Returns the margins of the page layout in device pixels for the given resolution.
Definition at line 733 of file qpagelayout.cpp.
References QPageLayoutPrivate::marginsPixels().
QMargins QPageLayout::marginsPoints | ( | ) | const |
Returns the margins of the page layout in Postscript Points (1/72 of an inch).
Definition at line 722 of file qpagelayout.cpp.
References QPageLayoutPrivate::marginsPoints().
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 780 of file qpagelayout.cpp.
QMarginsF QPageLayout::minimumMargins | ( | ) | const |
Returns the minimum margins of the page layout.
Definition at line 763 of file qpagelayout.cpp.
QPageLayout::Mode QPageLayout::mode | ( | ) | const |
Returns the page layout mode.
Definition at line 453 of file qpagelayout.cpp.
Referenced by QMacPrintEnginePrivate::newPage_helper(), QPdfEnginePrivate::pageMatrix(), setMode(), QMacPrintEngine::setProperty(), and QWin32PrintEngine::setProperty().
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 365 of file qpagelayout.cpp.
References other().
QPageLayout::Orientation QPageLayout::orientation | ( | ) | const |
Returns the page orientation of the page layout.
Definition at line 519 of file qpagelayout.cpp.
Referenced by QCupsPrintEnginePrivate::closePrintDevice(), QPrintPreviewWidgetPrivate::layoutPages(), QPrintDialogPrivate::openCocoaPrintPanel(), setOrientation(), QPdfPagedPaintDevicePrivate::setPageOrientation(), QPrinterPagedPaintDevicePrivate::setPageOrientation(), QMacPrintEnginePrivate::setPageSize(), QWin32PrintEnginePrivate::setPageSize(), QMacPrintEngine::setProperty(), QWin32PrintEngine::setProperty(), and QPageSetupWidget::setupPrinter().
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 488 of file qpagelayout.cpp.
Referenced by QCupsPrintEnginePrivate::closePrintDevice(), QMacPrintEnginePrivate::initialize(), QPrintDialogPrivate::openCocoaPrintPanel(), QWin32PrintEnginePrivate::setPageSize(), QPdfPagedPaintDevicePrivate::setPageSize(), QPrinterPagedPaintDevicePrivate::setPageSize(), setPageSize(), QMacPrintEngine::setProperty(), QCupsPrintEngine::setProperty(), and QWin32PrintEngine::setProperty().
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 851 of file qpagelayout.cpp.
References isValid(), and QPageLayoutPrivate::paintRect().
Referenced by QPrinter::pageRect(), and QWin32PrintEnginePrivate::updateMetrics().
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 866 of file qpagelayout.cpp.
References FullPageMode, QPageLayoutPrivate::fullRect(), isValid(), QPageLayoutPrivate::margins(), and QPageLayoutPrivate::paintRect().
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 904 of file qpagelayout.cpp.
References FullPageMode, QPageLayoutPrivate::fullRectPixels(), isValid(), and QPageLayoutPrivate::marginsPixels().
Referenced by QMacPrintEnginePrivate::newPage_helper(), QPdfEnginePrivate::pageMatrix(), QPrinter::pageRect(), QPrintPreviewWidgetPrivate::populateScene(), and QWin32PrintEnginePrivate::updateMetrics().
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 886 of file qpagelayout.cpp.
References FullPageMode, QPageLayoutPrivate::fullRectPoints(), isValid(), and QPageLayoutPrivate::marginsPoints().
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.
Definition at line 683 of file qpagelayout.cpp.
References QMarginsF::bottom(), QExplicitlySharedDataPointer< T >::detach(), FullPageMode, and QMarginsF::setBottom().
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.
Definition at line 602 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), FullPageMode, QMarginsF::left(), and QMarginsF::setLeft().
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.
Definition at line 565 of file qpagelayout.cpp.
References QMarginsF::bottom(), QExplicitlySharedDataPointer< T >::detach(), FullPageMode, QMarginsF::left(), margins(), QMarginsF::right(), and QMarginsF::top().
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 751 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), and QPageLayoutPrivate::setDefaultMargins().
Sets a page layout mode to mode.
Definition at line 443 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), and mode().
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 500 of file qpagelayout.cpp.
References QMarginsF::bottom(), QExplicitlySharedDataPointer< T >::detach(), QSizeF::height(), QMarginsF::left(), orientation(), QMarginsF::right(), QMarginsF::setBottom(), QMarginsF::setLeft(), QMarginsF::setRight(), QMarginsF::setTop(), QMarginsF::top(), and QSizeF::width().
Referenced by QWin32PrintEnginePrivate::updatePageLayout().
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 470 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), QPageSize::isValid(), pageSize(), and QPageLayoutPrivate::setDefaultMargins().
Referenced by QMacPrintEnginePrivate::setPageSize(), and QWin32PrintEnginePrivate::setPageSize().
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.
Definition at line 629 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), FullPageMode, QMarginsF::right(), and QMarginsF::setRight().
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.
Definition at line 656 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), FullPageMode, QMarginsF::setTop(), and QMarginsF::top().
Sets the units used to define the page layout.
Definition at line 528 of file qpagelayout.cpp.
References QExplicitlySharedDataPointer< T >::detach(), qt_convertMargins(), and units().
Referenced by QPageSetupWidget::setPrinter().
|
inlinenoexcept |
Swaps this page layout with other.
This function is very fast and never fails.
Definition at line 52 of file qpagelayout.h.
QPageLayout::Unit QPageLayout::units | ( | ) | const |
Returns the units the page layout is currently defined in.
Definition at line 544 of file qpagelayout.cpp.
Referenced by QPdfPagedPaintDevicePrivate::setPageMargins(), QPrinterPagedPaintDevicePrivate::setPageMargins(), QMacPrintEnginePrivate::setPageSize(), QWin32PrintEnginePrivate::setPageSize(), QPageSetupWidget::setPrinter(), QMacPrintEngine::setProperty(), QWin32PrintEngine::setProperty(), and setUnits().
|
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 102 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 100 of file qpagelayout.h.
|
friend |
Definition at line 97 of file qpagelayout.h.