- Qt 6.12
- Qt Multimedia
- QML Types
- WindowCapture
- Qt 6.12.0 Reference Documentation

# WindowCapture QML Type

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

Import Statement: | `import QtMultimedia`
Since: | Qt 6.6
In C++: | QWindowCapture

- List of all members, including inherited members

## Properties

- active : bool
- error : enumeration
- errorString : string
- frameRate : real `(since 6.12)`
- window : Window

## Signals

- errorChanged()
- errorOccurred(int error, string errorString)

## Methods

- list<CapturableWindow> capturableWindows()
- void start()
- void stop()

## Detailed Description

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

## Window Capture Limitations

The following limitations apply to using WindowCapture:

- WindowCapture is only supported with the FFmpeg backend.

The following limitations apply when using `QWindowCapture` on X11 systems:

- On Linux X11 systems, when a window is moved partially outside the visible screen area, only the visible region is captured. As a result, the emitted video frames may have a size smaller than the window’s geometry.
- Windows that are outside the visible screen area cannot be captured, and an error signal is emitted in that case.
- The behavior of minimized windows or those located on an invisible virtual workspace depends on the window manager. For example, such windows can be captured on GNOME, whereas on WindowMaker or Xfwm such capturing is not allowed, and the window capture instance emits an error.

See also CaptureSession and CapturableWindow.

## Property Documentation

### active : bool

Describes whether the capturing is currently active.

### error : enumeration `[read-only]`

Returns a code of the last error.

Constant | Description
--- | ---
`WindowCapture.NoError` | No error
`WindowCapture.InternalError` | Internal window capturing driver error
`WindowCapture.CapturingNotSupported` | Window capturing is not supported
`WindowCapture.CaptureFailed` | Capturing window failed
`WindowCapture.NotFound` | Selected window not found

### errorString : string `[read-only]`

Returns a human readable string describing the cause of error.

### frameRate : real `[since 6.12]`

The target window capture framerate.

Actual frame rate depends on the platform. For platforms with fixed rate capture, this frame rate is followed. For platforms with variable rate capture, this frame rate is either used as the polling rate (maximum frame rate) or completely ignored.

If -1, a platform-dependent default is used.

This property was introduced in Qt 6.12.

### window : Window

Describes the window for capturing.

Setting this property to an invalid window on an active WindowCapture will cause it to go inactive and emit an error.

See also capturableWindows.

## Signal Documentation

### errorChanged()

This signal is emitted when the error or errorString properties are changed.

This signal is not emitted whenever multiple identical errors are raised. To track such errors, use the signal errorOccurred.

Note: The corresponding handler is `onErrorChanged`.

### errorOccurred(int error, string errorString)

Signals when an error occurs, along with the errorString.

For the error parameter, see the enumeration table in error for what values may be passed.

Note: The corresponding handler is `onErrorOccurred`.

See also error.

## Method Documentation

### list<CapturableWindow> capturableWindows()

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

Note: On macOS, invoking this method will trigger the "Screen Recording" permission dialog. If permissions have not yet been granted, this method will return an empty list. Invoking it multiple times will bring this dialog to the foreground.

### void start()

Starts capturing the window.

This is equivalent to setting the active property to `true`.

### void stop()

Stops capturing.

This is equivalent to setting the active property to `false`.