Q3DSSurfaceViewer Class

Displays a Qt 3D Studio presentation on a surface. More...

Header: #include <q3dssurfaceviewer.h>
Inherits: QObject


  • 1 property inherited from QObject

Public Functions

Q3DSSurfaceViewer(QObject *parent = nullptr)
bool autoSize() const
QOpenGLContext *context() const
int fboId() const
QImage grab(const QRect &rect = QRect())
bool initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId = 0)
bool isRunning() const
Q3DSPresentation *presentation() const
Q3DSViewerSettings *settings() const
QSize size() const
QSurface *surface() const
int updateInterval() const
  • 32 public functions inherited from QObject

Public Slots

void reset()
void setAutoSize(bool autoSize)
void setSize(const QSize &size)
void setUpdateInterval(int interval)
void shutdown()
void update()
  • 1 public slot inherited from QObject


void autoSizeChanged(bool autoSize)
void frameUpdated()
void runningChanged(bool initialized)
void sizeChanged(const QSize &size)
void updateIntervalChanged(bool autoUpdate)

Additional Inherited Members

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

Detailed Description

Displays a Qt 3D Studio presentation on a surface.

Q3DSSurfaceViewer is used to specify a render surface for Qt 3D Studio presentation. Supported surface types are QOffscreenSurface and QWindow.

Example Usage

// Create a surface
QWindow window;

// Create an OpenGL context
QOpenGLContext context;

// Create the viewer
Q3DSSurfaceViewer viewer;

// Register a scene object for slide management (optional)
Q3DSSceneElement scene(viewer.presentation(), QStringLiteral("Scene"));

// Register an element object for attribute setting (optional)
Q3DSElement element(viewer.presentation(), QStringLiteral("Scene.Layer.myLabel"));

viewer.initialize(&window, &context);

See also Q3DSWidget.

Property Documentation

autoSize : bool

Specifies whether the viewer should change the size of the presentation automatically to match the surface size when surface size changes. The size property is updated automatically whenever the viewer is updated if this property value is true.

Note: For QOffscreenSurface, the surface size is typically 1x1, so generally you will want to set autoSize to false when using offscreen surfaces.

The default value is true.

Access functions:

bool autoSize() const
void setAutoSize(bool autoSize)

Notifier signal:

void autoSizeChanged(bool autoSize)

running : const bool

The value of this property is true when the viewer has been initialized and the presentation is running.

This property is read-only.

Access functions:

bool isRunning() const

Notifier signal:

void runningChanged(bool initialized)

size : QSize

Holds the desired size of the presentation.

The default value is (-1, -1).

Access functions:

QSize size() const
void setSize(const QSize &size)

Notifier signal:

void sizeChanged(const QSize &size)

See also autoSize.

updateInterval : int

Holds the viewer update interval in milliseconds. If the value is negative, the viewer doesn't update the presentation automatically.

The default value is -1.

Access functions:

int updateInterval() const
void setUpdateInterval(int interval)

Notifier signal:

void updateIntervalChanged(bool autoUpdate)

See also update().

Member Function Documentation

Q3DSSurfaceViewer::Q3DSSurfaceViewer(QObject *parent = nullptr)

Default constructs an instance of Q3DSSurfaceViewer.


Destroys the instance of Q3DSSurfaceViewer.

QOpenGLContext *Q3DSSurfaceViewer::context() const

Returns the context given in initialization.

See also initialize().

int Q3DSSurfaceViewer::fboId() const

Returns the framebuffer id given in initialization.

See also initialize().

[signal] void Q3DSSurfaceViewer::frameUpdated()

QImage Q3DSSurfaceViewer::grab(const QRect &rect = QRect())

Grabs the data rendered to the framebuffer into an image using the given rect. The rect parameter is optional. If it is omitted, the whole framebuffer is captured.

bool Q3DSSurfaceViewer::initialize(QSurface *surface, QOpenGLContext *context, GLuint fboId = 0)

Initializes Q3DSSurfaceViewer to render the presentation to the given surface using the context and optional framebuffer id (fboId). If fboId is omitted, it defaults to zero.

The source property of the attached presentation must be set before the viewer can be initialized.

Returns whether the initialization succeeded.

See also running, Q3DSPresentation::source, and presentation().

Q3DSPresentation *Q3DSSurfaceViewer::presentation() const

Returns the presentation object used by the Q3DSSurfaceViewer.

[slot] void Q3DSSurfaceViewer::reset()

Deallocates and recreates all resources of the viewer and sets the presentation time back to the beginning.

Q3DSViewerSettings *Q3DSSurfaceViewer::settings() const

Returns the settings object used by the Q3DSSurfaceViewer.

[slot] void Q3DSSurfaceViewer::shutdown()

Deallocates all resources of the viewer.

QSurface *Q3DSSurfaceViewer::surface() const

Returns the surface given in initialization.

See also initialize().

[slot] void Q3DSSurfaceViewer::update()

Updates the surface viewer with a new frame.

Available under certain Qt licenses.
Find out more.