PrintPage QML Type
An instance of this type represents the canvas of a printer page. More...
Import Statement: | import BrickStore 1.0 |
Properties
- backgroundColor : color
- color : color
- font : font
- lineStyle : enumeration
- lineWidth : real
- number : int
Methods
- drawEllipse(real left, real top, real width, real height)
- drawImage(real left, real top, real width, real height, image image)
- drawLine(real x1, real y1, real x2, real y2)
- drawRect(real left, real top, real width, real height)
- drawText(real left, real top, real width, real height, int flags, string text)
- size textSize(string text)
Detailed Description
Note: All coordinates are floating point values and the unit is mm
. Check PrintJob::paperSize to make sure you adapt to the paper format of the selected printer.
Property Documentation
backgroundColor : color |
The currently selected background color, used for filling rectangles and ellipses. Set to "transparent"
to prevent filling.
See the QML color documentation.
... page.backgroundColor = Qt.rgba(.13, .4, .66, 1) ...
The default is "white"
.
color : color |
The currently selected color, used for drawing text, lines and the outlines of rectangles and ellipses.
See the QML color documentation.
... page.color = active ? "black" : "#808080" ...
The default is "black"
.
font : font |
The currently selected font. You can create and assign font objects using the Qt.font()
factory function.
See the Qt documentation for Qt.font and the QML font documentation for the available font properties.
... page.font = Qt.font({ family: "Times", pointSize: 12 }) ...
The default is { family: "Arial", pointSize: 10 }
.
lineStyle : enumeration |
The style of lines, used for drawing lines and the outlines of rectangles and ellipses.
The available values for this line style enumeration are:
Constant | Description |
---|---|
PrintPage.SolidLine | A plain line. |
PrintPage.NoLine | No line at all. For example, drawRect fills but does not draw any outline. |
PrintPage.DashLine | Dashes separated by a few pixels. |
PrintPage.DotLine | Dots separated by a few pixels. |
PrintPage.DashDotLine | Alternate dots and dashes. |
PrintPage.DashDotDotLine | One dash, two dots, one dash, two dots. |
The default is PrintPage.SolidLine
.
lineWidth : real |
The width of a line, used for drawing lines and the outlines of rectangles and ellipses.
A line width of zero indicates a cosmetic pen. This means that the pen width is always drawn one pixel wide, independent of the actual pixel density and resolution of the current output device.
The default is 0.1
.
number : int |
The page index within the current print job.
See also PrintJob.
Method Documentation
drawEllipse(real left, real top, real width, real height) |
Draws an ellipse within the rectangle specified by the top-left corner at (left, top) and a size of (width x height).
The ellipse is filled with backgroundColor and the outline is drawn using a lineWidth thick pencil using the selected color and lineStyle.
drawImage(real left, real top, real width, real height, image image) |
Draws the given image with its top-left corner at (left, top), scaled to the size (width x height).
drawLine(real x1, real y1, real x2, real y2) |
Draws a line from (x1, y1) to (x2, y2) using color.
drawRect(real left, real top, real width, real height) |
Draws a rectangle with the top-left corner at (left, top) and a size of (width x height).
The rectangle is filled with backgroundColor and the outline is drawn using a lineWidth thick pencil using the selected color and lineStyle.
drawText(real left, real top, real width, real height, int flags, string text) |
Draws the given text within the rectangle specified by the top-left corner at (left, top) and a size of (width x height) using the currently selected font and color.
If the text is larger than the specified rectangle, the text is clipped. You can use textSize() to calculate the size needed to fit a specific text element. You can suppress this feature using the TextDontClip
flag.
The text can be aligned within this rectangle through the flags parameter. These possible are the possible values and can you can or them (|
) together where it makes sense:
Constant | Description |
---|---|
PrintPage.AlignLeft | Aligns with the left edge. |
PrintPage.AlignHCenter | Centers horizontally in the available space. |
PrintPage.AlignRight | Aligns with the right edge. |
PrintPage.AlignTop | Aligns with the top. |
PrintPage.AlignVCenter | Centers vertically in the available space. |
PrintPage.AlignBottom | Aligns with the bottom. |
PrintPage.AlignCenter | Centers in both dimensions. |
PrintPage.TextDontClip | If it's impossible to stay within the given bounds, it prints outside. |
PrintPage.TextWordWrap | Breaks lines at appropriate points, e.g. at word boundaries. |
PrintPage.TextWrapAnywhere | Breaks lines anywhere, even within words. |
size textSize(string text) |
Calculates the size of string text, if it was rendered in the currently selected font.
© 2004-2025 Robert Griebl. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. All trademarks are property of their respective owners.