- Qt 6.11
- Qt WebEngine
- C++ Classes
- QtWebEngineCore
- QWebEngineDesktopMediaRequest
- Qt 6.11.0 Reference Documentation

# QWebEngineDesktopMediaRequest Class

A request for populating a dialog with available sources for screen capturing. More...

Header: | `#include <QWebEngineDesktopMediaRequest>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)` `target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)`
qmake: | `QT += webenginecore`
Since: | Qt 6.7
In QML: | webEngineDesktopMediaRequest

- List of all members, including inherited members

## Properties

- screensModel : QAbstractListModel*
- windowsModel : QAbstractListModel*

## Public Functions

void | cancel() const
QAbstractListModel * | screensModel() const
void | selectScreen(const QModelIndex &index) const
void | selectWindow(const QModelIndex &index) const
QAbstractListModel * | windowsModel() const

## Detailed Description

To allow web applications to capture contents of a display, applications must connect to QWebEnginePage::desktopMediaRequested, which takes a QWebEngineDesktopMediaRequest instance as an argument.

If a web application requests access to the contents of a display, QWebEnginePage::desktopMediaRequested will be emitted with a QWebEngineDesktopMediaRequest instance as an argument which holds references to QAbstractListModels for available windows and screens that can be captured.

The data model's Qt::DisplayRole specifies the name of the source which is the title of a window or the number of the display. The model is dynamically updated if the available list of sources has changed; e.g when a window is opened/closed.

The signal handler needs to then either call selectScreen() or selectWindow() to accept the request and start screensharing.

See also QWebEnginePage::desktopMediaRequested().

## Property Documentation

### `[read-only]` screensModel : QAbstractListModel*

This property holds a QAbstractListModel for the available screens.

Access functions:

QAbstractListModel * | screensModel() const

See also windowsModel.

### `[read-only]` windowsModel : QAbstractListModel*

This property holds a QAbstractListModel for the available windows.

Access functions:

QAbstractListModel * | windowsModel() const

See also screensModel.

## Member Function Documentation

### `[invokable]` void QWebEngineDesktopMediaRequest::cancel() const

Rejects a request. Screen capturing will be aborted.

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

### `[invokable]` void QWebEngineDesktopMediaRequest::selectScreen(const QModelIndex &index) const

Selects the screen at the index to be captured.

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

See also QWebEngineDesktopMediaRequest::selectWindow().

### `[invokable]` void QWebEngineDesktopMediaRequest::selectWindow(const QModelIndex &index) const

Selects the window at the index to be captured.

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

See also QWebEngineDesktopMediaRequest::selectScreen().