- 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

## 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().

## 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.

### QAbstractListModel *QWebEngineDesktopMediaRequest::screensModel() const

Returns a QAbstractListModel for the available screens.

Note: Getter function for property screensModel.

See also windowsModel().

### `[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().

### QAbstractListModel *QWebEngineDesktopMediaRequest::windowsModel() const

Returns a QAbstractListModel for the available windows.

Note: Getter function for property windowsModel.

See also screensModel().