PySide6.QtQuick.QSGTextNode¶
- class QSGTextNode¶
- The - QSGTextNodeclass is a class for drawing text layouts and text documents in the Qt Quick scene graph.- Details- QSGTextNodecan 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 - QSGTextNodeobjects using- createTextNode(). The- addTextLayout()and- addTextDocument()functions provide ways to add text to the- QSGTextNode. The text must already be laid out.- Note - Properties must be set before - addTextLayout()or- addTextDocument()are called in order to have an effect.- Note - The destruction of - QSGTextNodehas to be managed with care. In particular, since it references graphics resources, it must be deleted when the Qt Quick scene graph is invalidated. If the node is part of the graph and has the- OwnedByParentflag set (which is the default), this will happen automatically. However, if the- OwnedByParentflag is cleared and the node is disposed of manually, care must be taken to do this when the scene graph is invalidated. This can be done by connecting to the- sceneGraphInvalidated()signal, or by implementing a slot in the- QQuickItemsubclass which is named- invalidateSceneGraph(). See also the documentation of- QQuickItemfor more details.- Added in version 6.7. - Synopsis¶- Methods¶
- def - addTextLayout()
 - Virtual methods¶- 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 - class TextStyle¶
- This enum type describes styles that can be applied to text rendering. - Constant - Description - QSGTextNode.TextStyle.Normal - The text is drawn without any style applied. - QSGTextNode.TextStyle.Outline - The text is drawn with an outline. - QSGTextNode.TextStyle.Raised - The text is drawn raised. - QSGTextNode.TextStyle.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.RenderType.QtRendering - Text is rendered using a scalable distance field for each glyph. - QSGTextNode.RenderType.NativeRendering - Text is rendered using a platform-specific technique. - QSGTextNode.RenderType.CurveRendering - Text is rendered using a curve rasterizer running directly on the graphics hardware. - Select - NativeRenderingif 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.QtRenderingand- Text.CurveRenderingare hardware-accelerated techniques.- QtRenderingis the faster of the two, but uses more memory and will exhibit rendering artifacts at large sizes.- CurveRenderingshould be considered as an alternative in cases where- QtRenderingdoes not give good visual results or where reducing graphics memory consumption is a priority.- See also 
 - addTextDocument(position, document[, selectionStart=-1[, selectionCount=-1]])¶
- Parameters:
- position – - QPointF
- document – - QTextDocument
- selectionStart – int 
- selectionCount – int 
 
 
 - Adds the contents of - documentto the text node at- position. If- selectionStartis >= 0, then this marks the first character in a selected area of- selectionCountnumber of characters. The selection is represented as a background fill with the- selectionColor()and the selected text is rendered in the- selectionTextColor().- This function forwards its arguments to the virtual function doAddTextDocument(). - See also - 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 - layoutto the text node at- position. If- selectionStartis >= 0, then this marks the first character in a selected area of- selectionCountnumber of characters. The selection is represented as a background fill with the- selectionColor()and the selected text is rendered in the- selectionTextColor().- For convenience, - lineStartand- lineCountcan be used to select the range of QTextLine objects to include from the layout. This can be useful, for instance, when creating elided layouts. If- lineCountis < 0, then the the node will include the lines from- lineStartto the end of the layout.- This function forwards its arguments to the virtual function doAddTextLayout(). - 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, use- Linearhere.- The default is - Nearest.- See also - Sets the color of or hyperlinks to - linkColorin 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 - renderTypeQualityis < 0, the default quality is used.- The - renderTypeQualitycan 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 - QtRenderingrender 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 - colorwhen 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 - selectionTextColorwhen 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 is- Normal.- See also - Sets the bounding rect of the viewport where the text is displayed to - viewport. Providing this information makes it possible for the- QSGTextNodeto 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