QScene2D Class

(Qt3DRender::Quick::QScene2D)

This class enables rendering qml into a texture, which then can be used as a part of 3D scene. More...

Header: #include <QScene2D>
qmake: QT += 3dquickscene2d
Since: Qt 5.9
Instantiated By: Scene2D
Inherits: Qt3DCore::QNode

Public Types

enum RenderPolicy { Continuous, SingleShot }

Properties

Public Functions

QScene2D(Qt3DCore::QNode *parent = nullptr)
QScene2D(QQmlEngine *engine, Qt3DCore::QNode *parent = nullptr)
~QScene2D()
void addEntity(Qt3DCore::QEntity *entity)
QQmlEngine *engine() const
QVector<Qt3DCore::QEntity *> entities()
bool isGrabMouseEnabled() const
QQuickItem *item() const
bool loaded() const
Qt3DRender::QRenderTargetOutput *output() const
void removeEntity(Qt3DCore::QEntity *entity)
QScene2D::RenderPolicy renderPolicy() const
QUrl source() const

Reimplemented Public Functions

virtual bool event(QEvent *event)

Public Slots

void setGrabMouseEnabled(bool grab)
void setItem(QQuickItem *item)
void setOutput(Qt3DRender::QRenderTargetOutput *output)
void setRenderPolicy(QScene2D::RenderPolicy policy)
void setSource(const QUrl &url)

Signals

void grabMouseChanged(bool grab)
void itemChanged(QQuickItem *item)
void loadedChanged(bool loaded)
void outputChanged(Qt3DRender::QRenderTargetOutput *output)
void renderPolicyChanged(QScene2D::RenderPolicy policy)
void sourceChanged(const QUrl &url)

Additional Inherited Members

  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 2 protected functions inherited from Qt3DCore::QNode
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

This class enables rendering qml into a texture, which then can be used as a part of 3D scene.

The component uses QQuickRenderControl to render the given QML source into an offscreen surface, which is attached to a texture provided by the user. This allows the component to directly render into the texture without intermediate copy and the user to freely specify how the texture is used in the 3D scene.

Member Type Documentation

enum QScene2D::RenderPolicy

This enum type describes types of render policies available.

ConstantValueDescription
Qt3DRender::Quick::QScene2D::Continuous0The Scene2D is rendering continuously. This is the default render policy.
Qt3DRender::Quick::QScene2D::SingleShot1The Scene2D renders to the texture only once after which the resources allocated for rendering are released.

Property Documentation

grabMouse : bool

Access functions:

bool isGrabMouseEnabled() const
void setGrabMouseEnabled(bool grab)

Notifier signal:

void grabMouseChanged(bool grab)

item : QQuickItem *

Access functions:

QQuickItem *item() const
void setItem(QQuickItem *item)

Notifier signal:

void itemChanged(QQuickItem *item)

loaded : const bool

Access functions:

bool loaded() const

Notifier signal:

void loadedChanged(bool loaded)

output : Qt3DRender::QRenderTargetOutput *

Holds the QRenderTargetOutput, which specifies where the QScene2D is rendering to.

Access functions:

Qt3DRender::QRenderTargetOutput *output() const
void setOutput(Qt3DRender::QRenderTargetOutput *output)

Notifier signal:

void outputChanged(Qt3DRender::QRenderTargetOutput *output)

renderPolicy : QScene2D::RenderPolicy

Holds the render policy of this Scene2D.

Access functions:

QScene2D::RenderPolicy renderPolicy() const
void setRenderPolicy(QScene2D::RenderPolicy policy)

Notifier signal:

void renderPolicyChanged(QScene2D::RenderPolicy policy)

source : QUrl

Specifies the url for the qml.

This property specifies the url to the qml being rendered to the texture. The source must specify QQuickItem as a root. The item must specify width and height. The rendered qml is scaled to the texture size. The property can not be changed after the rendering has been initialized.

Access functions:

QUrl source() const
void setSource(const QUrl &url)

Notifier signal:

void sourceChanged(const QUrl &url)

Member Function Documentation

QScene2D::QScene2D(Qt3DCore::QNode *parent = nullptr)

The constructor creates a new QScene2D instance with the specified parent.

QScene2D::QScene2D(QQmlEngine *engine, Qt3DCore::QNode *parent = nullptr)

Default constructs an instance of QScene2D.

QScene2D::~QScene2D()

Destroys the instance of QScene2D.

void QScene2D::addEntity(Qt3DCore::QEntity *entity)

QQmlEngine *QScene2D::engine() const

Returns the qml engine used by the QScene2D.

QVector<Qt3DCore::QEntity *> QScene2D::entities()

[virtual] bool QScene2D::event(QEvent *event)

void QScene2D::removeEntity(Qt3DCore::QEntity *entity)