QWindowCapture Class | Qt Multimedia 6.8.0
Description: This class is used for capturing a window.

- Qt 6.8
- Qt Multimedia
- C++ Classes
- QtMultimedia
- QWindowCapture
- Qt 6.8.0 Reference Documentation

# QWindowCapture Class

This class is used for capturing a window. More...

Header: | #include <QWindowCapture>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Multimedia) target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: | QT += multimedia
Since: | Qt 6.6
Instantiated By: | WindowCapture
Inherits: | QObject

- List of all members, including inherited members

## Public Types

enum | Error { NoError, InternalError, CapturingNotSupported, CaptureFailed, NotFound }

## Properties

- active : bool
- error : const Error
- errorString : const QString
- window : QCapturableWindow

## Public Functions

| QWindowCapture(QObject *parent = nullptr)
virtual | ~QWindowCapture() override
QWindowCapture::Error | error() const
QString | errorString() const
bool | isActive() const
void | setWindow(QCapturableWindow window)
QCapturableWindow | window() const

## Public Slots

void | setActive(bool active)
void | start()
void | stop()

## Signals

void | activeChanged(bool)
void | errorChanged()
void | errorOccurred(QWindowCapture::Error error, const QString &errorString)
void | windowChanged(QCapturableWindow window)

## Static Public Members

QList<QCapturableWindow> | capturableWindows()

## Detailed Description

The class captures a window. It is managed by the QMediaCaptureSession class where the captured window can be displayed in a video preview object or recorded to a file.

See also QMediaCaptureSession and QCapturableWindow.

## Member Type Documentation

### enum QWindowCapture::Error

Enumerates error codes that can be signaled by the QWindowCapture class. errorString() provides detailed information about the error cause.

Constant | Value | Description
--- | --- | ---
`QWindowCapture::NoError` | `0` | No error
`QWindowCapture::InternalError` | `1` | Internal window capturing driver error
`QWindowCapture::CapturingNotSupported` | `2` | Window capturing is not supported
`QWindowCapture::CaptureFailed` | `4` | Capturing window failed
`QWindowCapture::NotFound` | `5` | Selected window not found

## Property Documentation

### active : bool

This property holds whether the capturing is currently active.

Access functions:

bool | isActive() const
void | setActive(bool active)

Notifier signal:

void | activeChanged(bool)

See also start() and stop().

### `[read-only]` error : const Error

This property holds the code of the last error.

Access functions:

QWindowCapture::Error | error() const

Notifier signal:

void | errorChanged()

### `[read-only]` errorString : const QString

This property holds a human readable string describing the cause of error.

Access functions:

QString | errorString() const

Notifier signal:

void | errorChanged()

### window : QCapturableWindow

This property holds the window for capturing.

Access functions:

QCapturableWindow | window() const
void | setWindow(QCapturableWindow window)

Notifier signal:

void | windowChanged(QCapturableWindow window)

See also QWindowCapture::capturableWindows.

## Member Function Documentation

### `[explicit]` QWindowCapture::QWindowCapture(QObject *parent = nullptr)

Constructs a new QWindowCapture object with parent.

### `[override virtual noexcept]` QWindowCapture::~QWindowCapture()

Destroys the object.

### `[static invokable]` QList<QCapturableWindow> QWindowCapture::capturableWindows()

Returns a list of QCapturableWindow objects that is available for capturing.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[signal]` void QWindowCapture::errorOccurred(QWindowCapture::Error error, const QString &errorString)

Signals when an error occurs, along with the errorString.

### `[slot]` void QWindowCapture::start()

Starts capturing the window.

This is equivalent to setting the active property to true.

### `[slot]` void QWindowCapture::stop()

Stops capturing.

This is equivalent to setting the active property to false.