- class QSGTextNode#
The
QSGTextNode
class is a class for drawing text layouts and text documents in the Qt Quick scene graph. More…New in version 6.7.
Synopsis#
Virtual methods#
def
addTextLayout()
def
clear()
def
color()
def
filtering()
def
linkColor()
def
renderType()
def
selectionColor()
def
setColor()
def
setFiltering()
def
setLinkColor()
def
setRenderType()
def
setStyleColor()
def
setTextStyle()
def
setViewport()
def
styleColor()
def
textStyle()
def
viewport()
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#
QSGTextNode
can be useful for creating custom Qt Quick items that require text. It is used in Qt Quick by the Text, TextEdit and TextInput elements.You can create
QSGTextNode
objects usingcreateTextNode()
. TheaddTextLayout()
andaddTextDocument()
functions provide ways to add text to theQSGTextNode
. The text must already be laid out.Note
Properties must be set before
addTextLayout()
oraddTextDocument()
are called in order to have an effect.- class TextStyle#
This enum type describes styles that can be applied to text rendering.
Constant
Description
QSGTextNode.Normal
The text is drawn without any style applied.
QSGTextNode.Outline
The text is drawn with an outline.
QSGTextNode.Raised
The text is drawn raised.
QSGTextNode.Sunken
The text is drawn sunken.
See also
- class RenderType#
This enum type describes type of glyph node used for rendering the text.
Constant
Description
QSGTextNode.QtRendering
Text is rendered using a scalable distance field for each glyph.
QSGTextNode.NativeRendering
Text is rendered using a platform-specific technique.
QSGTextNode.CurveRendering
Text is rendered using a curve rasterizer running directly on the graphics hardware.
Select
NativeRendering
if you prefer text to look native on the target platform and do not require advanced features such as transformation of the text. Using such features in combination with the NativeRendering render type will lend poor and sometimes pixelated results.Both
Text.QtRendering
andText.CurveRendering
are hardware-accelerated techniques.QtRendering
is the faster of the two, but uses more memory and will exhibit rendering artifacts at large sizes.CurveRendering
should be considered as an alternative in cases whereQtRendering
does not give good visual results or where reducing graphics memory consumption is a priority.See also
- abstract addTextDocument(position, document[, selectionStart=-1[, selectionCount=-1]])#
- Parameters:
position –
QPointF
document –
QTextDocument
selectionStart – int
selectionCount – int
Adds the contents of
document
to the text node atposition
. IfselectionStart
is >= 0, then this marks the first character in a selected area ofselectionCount
number of characters. The selection is represented as a background fill with theselectionColor()
and the selected text is rendered in theselectionTextColor()
.See also
- abstract addTextLayout(position, layout[, selectionStart=-1[, selectionCount=-1[, lineStart=0[, lineCount=-1]]]])#
- Parameters:
position –
QPointF
layout –
QTextLayout
selectionStart – int
selectionCount – int
lineStart – int
lineCount – int
Adds the contents of
layout
to the text node atposition
. IfselectionStart
is >= 0, then this marks the first character in a selected area ofselectionCount
number of characters. The selection is represented as a background fill with theselectionColor()
and the selected text is rendered in theselectionTextColor()
.For convenience,
lineStart
andlineCount
can be used to select the range of QTextLine objects to include from the layout. This can be useful, for instance, when creating elided layouts. IflineCount
is < 0, then the the node will include the lines fromlineStart
to the end of the layout.See also
- abstract clear()#
Clears the contents of the node, deleting nodes and other data that represents the layouts and documents that have been added to it.
See also
Returns the main color used when rendering the text.
See also
Returns the sampling mode used when scaling images that are part of the displayed text.
See also
Returns the color of hyperlinks in the text.
See also
- abstract renderType()#
- Return type:
Returns the type of glyph node used for rendering the text.
See also
- abstract renderTypeQuality()#
- Return type:
int
Returns the render type quality of the node. See
setRenderTypeQuality()
for details.See also
Returns the color of the selection background when any part of the text is marked as selected.
See also
Returns the color of the selection text when any part of the text is marked as selected.
See also
Sets the main color to use when rendering the text to
color
.The default is black:
QColor(0, 0, 0)
.See also
Sets the sampling mode used when scaling images that are part of the displayed text to
filtering
. For smoothly scaled images, useLinear
here.The default is
Nearest
.See also
Sets the color of or hyperlinks to
linkColor
in the text.The default is blue:
QColor(0, 0, 255)
.See also
- abstract setRenderType(renderType)#
- Parameters:
renderType –
RenderType
Sets the type of glyph node in use to
renderType
.The default is
QtRendering
.See also
- abstract setRenderTypeQuality(renderTypeQuality)#
- Parameters:
renderTypeQuality – int
If the
renderType()
in use supports it, set the quality to use when rendering the text. When supported, this can be used to trade visual fidelity for execution speed or memory.When the
renderTypeQuality
is < 0, the default quality is used.The
renderTypeQuality
can be any integer, although limitations imposed by the underlying graphics hardware may be encountered if extreme values are set. The Qt Quick Text element operates with the following predefined values:DefaultRenderTypeQuality
-1 (default)
This value is currently only respected by the
QtRendering
render type. Setting it changes the resolution of the distance fields used to represent the glyphs. Setting it above normal will cause memory consumption to increase, but reduces filtering artifacts on very large text.The default is -1.
See also
Sets the color of the selection background to
color
when any part of the text is marked as selected.The default is dark blue:
QColor(0, 0, 128)
.See also
Sets the color of the selection text to
selectionTextColor
when any part of the text is marked as selected.The default is white:
QColor(255, 255, 255)
.See also
Sets the style color to use when rendering the text to
styleColor
.The default is black:
QColor(0, 0, 0)
.See also
Sets the style of the rendered text to
textStyle
. The default isNormal
.See also
Sets the bounding rect of the viewport where the text is displayed to
viewport
. Providing this information makes it possible for theQSGTextNode
to optimize which parts of the text layout or document are included in the scene graph.The default is a default-constructed QRectF. For this viewport, all contents will be included in the graph.
See also
Returns the style color used when rendering the text.
See also
Returns the style of the rendered text.
See also
Returns the current viewport set for this
QSGTextNode
.See also