class QQuickRenderTarget#

The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a render target, and associated metadata. More

Synopsis#

Methods#

Static functions#

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#

__init__()#

Constructs a default QQuickRenderTarget that does not reference any native objects.

__init__(other)
Parameters:

otherQQuickRenderTarget

devicePixelRatio()#
Return type:

float

Returns the device pixel ratio for the render target. This is the ratio between device pixels and device independent pixels.

The default device pixel ratio is 1.0.

static fromOpenGLRenderBuffer(renderbufferId, pixelSize[, sampleCount=1])#
Parameters:
  • renderbufferId – int

  • pixelSizeQSize

  • sampleCount – int

Return type:

QQuickRenderTarget

Returns a new QQuickRenderTarget referencing an OpenGL renderbuffer object specified by renderbufferId.

The renderbuffer will be used as the color attachment for the internal framebuffer object. This function is provided to allow targeting renderbuffers that are created by the application with some external buffer underneath, such as an EGLImageKHR. Once the application has called glEGLImageTargetRenderbufferStorageOES , the renderbuffer can be passed to this function.

pixelSize specifies the size of the image, in pixels.

sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample renderbuffer.

Note

the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.

static fromOpenGLTexture(textureId, pixelSize[, sampleCount=1])#
Parameters:
  • textureId – int

  • pixelSizeQSize

  • sampleCount – int

Return type:

QQuickRenderTarget

This is an overloaded function.

Returns a new QQuickRenderTarget referencing an OpenGL texture object specified by textureId. The texture is assumed to have a format of GL_RGBA (GL_RGBA8).

pixelSize specifies the size of the image, in pixels. Currently only 2D textures are supported.

sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample texture.

The texture is used as the first color attachment of the render target used by the Qt Quick scenegraph. A depth-stencil buffer, if applicable, is created and used automatically.

The OpenGL object name textureId must be a valid name in the rendering context used by the Qt Quick scenegraph.

Note

the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.

static fromOpenGLTexture(textureId, format, pixelSize[, sampleCount=1])
Parameters:
  • textureId – int

  • format – int

  • pixelSizeQSize

  • sampleCount – int

Return type:

QQuickRenderTarget

Returns a new QQuickRenderTarget referencing an OpenGL texture object specified by textureId.

format specifies the native internal format of the texture. Only texture formats that are supported by Qt’s rendering infrastructure should be used.

pixelSize specifies the size of the image, in pixels. Currently only 2D textures are supported.

sampleCount specific the number of samples. 0 or 1 means no multisampling, while a value like 4 or 8 states that the native object is a multisample texture.

The texture is used as the first color attachment of the render target used by the Qt Quick scenegraph. A depth-stencil buffer, if applicable, is created and used automatically.

The OpenGL object name textureId must be a valid name in the rendering context used by the Qt Quick scenegraph.

Note

the resulting QQuickRenderTarget does not own any native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the native resource exists as long as necessary.

static fromPaintDevice(device)#
Parameters:

deviceQPaintDevice

Return type:

QQuickRenderTarget

Returns a new QQuickRenderTarget referencing a paint device object specified by device.

This option of redirecting rendering to a QPaintDevice is available only when running with the software backend of Qt Quick.

Note

The QQuickRenderTarget does not take ownship of device, it is the caller’s responsibility to ensure the object exists as long as necessary.

static fromRhiRenderTarget(renderTarget)#
Parameters:

renderTargetQRhiRenderTarget

Return type:

QQuickRenderTarget

Returns a new QQuickRenderTarget referencing an existing renderTarget.

renderTarget will in most cases be a QRhiTextureRenderTarget, which allows directing the Qt Quick scene’s rendering into a QRhiTexture.

Note

the resulting QQuickRenderTarget does not own renderTarget and any underlying native resources, it merely contains references and the associated metadata of the size and sample count. It is the caller’s responsibility to ensure that the referenced resources exists as long as necessary.

isNull()#
Return type:

bool

Returns true if this QQuickRenderTarget is default constructed, referencing no native objects.

mirrorVertically()#
Return type:

bool

Returns Returns whether the render target is mirrored vertically.

The default value is false.

__ne__(rhs)#
Parameters:

rhsQQuickRenderTarget

Return type:

bool

Returns true if a and b refer to a different set of native objects, or the associated data (size, sample count) does not match.

__eq__(rhs)#
Parameters:

rhsQQuickRenderTarget

Return type:

bool

Returns true if a and b refer to the same set of native objects and have matching associated data (size, sample count).

setDevicePixelRatio(ratio)#
Parameters:

ratio – float

Sets the device pixel ratio for this render target to ratio. This is the ratio between device pixels and device independent pixels.

Note that the specified device pixel ratio value will be ignored if renderWindow() is re-implemented to return a valid QWindow.

setMirrorVertically(enable)#
Parameters:

enable – bool

Sets the size of the render target contents should be mirrored vertically to enable when drawing. This allows easy integration of third-party rendering code that does not follow the standard expectations.

Note

This function should not be used when using the software backend.