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

# QWebEngineContextMenuRequest Class

The QWebEngineContextMenuRequest class provides request for populating or extending a context menu with actions. More...

Header: | `#include <QWebEngineContextMenuRequest>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)` `target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)`
qmake: | `QT += webenginecore`
Since: | Qt 6.2
Inherits: | QObject

- List of all members, including inherited members

## Public Types

`(since 6.2)` enum | EditFlag { CanUndo, CanRedo, CanCut, CanCopy, CanPaste, …, CanEditRichly }
flags | EditFlags
`(since 6.2)` enum | MediaFlag { MediaInError, MediaPaused, MediaMuted, MediaLoop, MediaCanSave, …, MediaCanRotate }
flags | MediaFlags
`(since 6.2)` enum | MediaType { MediaTypeNone, MediaTypeImage, MediaTypeVideo, MediaTypeAudio, MediaTypeCanvas, …, MediaTypePlugin }

## Properties

accepted : bool editFlags : const EditFlags isContentEditable : const bool linkText : const QString linkUrl : const QUrl mediaFlags : const MediaFlags | mediaType : const MediaType mediaUrl : const QUrl misspelledWord : const QString position : const QPoint selectedText : const QString spellCheckerSuggestions : const QStringList

## Public Functions

virtual | ~QWebEngineContextMenuRequest()
QWebEngineContextMenuRequest::EditFlags | editFlags() const
bool | isAccepted() const
bool | isContentEditable() const
QString | linkText() const
QUrl | linkUrl() const
QWebEngineContextMenuRequest::MediaFlags | mediaFlags() const
QWebEngineContextMenuRequest::MediaType | mediaType() const
QUrl | mediaUrl() const
QString | misspelledWord() const
QPoint | position() const
QString | selectedText() const
void | setAccepted(bool accepted)
QStringList | spellCheckerSuggestions() const

## Detailed Description

QWebEngineContextMenuRequest is returned by QWebEngineView::lastContextMenuRequest() after a context menu event, and contains information about where the context menu event took place. This is also in the context in which any context specific QWebEnginePage::WebAction will be performed.

## Member Type Documentation

### `[since 6.2]` enum QWebEngineContextMenuRequest::EditFlag
flags QWebEngineContextMenuRequest::EditFlags

The available edit operations in the current context menu request.

Constant | Value | Description
--- | --- | ---
`QWebEngineContextMenuRequest::CanUndo` | `0x1` | Undo is available.
`QWebEngineContextMenuRequest::CanRedo` | `0x2` | Redo is available.
`QWebEngineContextMenuRequest::CanCut` | `0x4` | Cut is available.
`QWebEngineContextMenuRequest::CanCopy` | `0x8` | Copy is available.
`QWebEngineContextMenuRequest::CanPaste` | `0x10` | Paste is available.
`QWebEngineContextMenuRequest::CanDelete` | `0x20` | Delete is available.
`QWebEngineContextMenuRequest::CanSelectAll` | `0x40` | Select All is available.
`QWebEngineContextMenuRequest::CanTranslate` | `0x80` | Translate is available.
`QWebEngineContextMenuRequest::CanEditRichly` | `0x100` | Context is richly editable.

This enum was introduced in Qt 6.2.

The EditFlags type is a typedef for QFlags<EditFlag>. It stores an OR combination of EditFlag values.

### `[since 6.2]` enum QWebEngineContextMenuRequest::MediaFlag
flags QWebEngineContextMenuRequest::MediaFlags

The current media element's status and its available operations. `MediaNone` if the selected web page content is not a media element.

Constant | Value | Description
--- | --- | ---
`QWebEngineContextMenuRequest::MediaInError` | `0x1` | An error occurred.
`QWebEngineContextMenuRequest::MediaPaused` | `0x2` | Media is paused.
`QWebEngineContextMenuRequest::MediaMuted` | `0x4` | Media is muted.
`QWebEngineContextMenuRequest::MediaLoop` | `0x8` | Media can be looped.
`QWebEngineContextMenuRequest::MediaCanSave` | `0x10` | Media can be saved.
`QWebEngineContextMenuRequest::MediaHasAudio` | `0x20` | Media has audio.
`QWebEngineContextMenuRequest::MediaCanToggleControls` | `0x40` | Media can show controls.
`QWebEngineContextMenuRequest::MediaControls` | `0x80` | Media controls are shown.
`QWebEngineContextMenuRequest::MediaCanPrint` | `0x100` | Media is printable.
`QWebEngineContextMenuRequest::MediaCanRotate` | `0x200` | Media is rotatable.

This enum was introduced in Qt 6.2.

The MediaFlags type is a typedef for QFlags<MediaFlag>. It stores an OR combination of MediaFlag values.

### `[since 6.2]` enum QWebEngineContextMenuRequest::MediaType

This enum describes the media type of the context menu request if any.

Constant | Value | Description
--- | --- | ---
`QWebEngineContextMenuRequest::MediaTypeNone` | `0` | The context is not a media type.
`QWebEngineContextMenuRequest::MediaTypeImage` | `1` | The context is an image element.
`QWebEngineContextMenuRequest::MediaTypeVideo` | `2` | The context is a video element.
`QWebEngineContextMenuRequest::MediaTypeAudio` | `3` | The context is an audio element.
`QWebEngineContextMenuRequest::MediaTypeCanvas` | `4` | The context is a canvas element.
`QWebEngineContextMenuRequest::MediaTypeFile` | `5` | The context is a file.
`QWebEngineContextMenuRequest::MediaTypePlugin` | `6` | The context is a plugin element.

This enum was introduced in Qt 6.2.

## Property Documentation

### accepted : bool

This property holds whether the request is accepted.

Access functions:

bool | isAccepted() const
void | setAccepted(bool accepted)

### `[read-only]` editFlags : const EditFlags

This property holds the available edit operations in the current context.

Returns `CanDoNone` if no actions are available.

Access functions:

QWebEngineContextMenuRequest::EditFlags | editFlags() const

### `[read-only]` isContentEditable : const bool

This property holds whether the context menu request is editable by the user.

Access functions:

bool | isContentEditable() const

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

This property holds the text of a link if the context menu request was requested for a link.

Access functions:

QString | linkText() const

### `[read-only]` linkUrl : const QUrl

This property holds the URL of a link if the menu context request is a link.

It is not guaranteed to be a valid URL.

Access functions:

QUrl | linkUrl() const

### `[read-only]` mediaFlags : const MediaFlags

This property holds the current media element's status and its available operations.

Returns `MediaNone` if the selected web page content is not a media element.

Access functions:

QWebEngineContextMenuRequest::MediaFlags | mediaFlags() const

### `[read-only]` mediaType : const MediaType

This property holds the type of the media element or `MediaTypeNone` if the context menu request is not a media element.

Access functions:

QWebEngineContextMenuRequest::MediaType | mediaType() const

### `[read-only]` mediaUrl : const QUrl

This property holds the URL of the media element if the context menu request is a media element.

Access functions:

QUrl | mediaUrl() const

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

This property holds the misspelled word if the menu context request is a word considered misspelled by the spell-checker.

For possible replacements of the word, see spellCheckerSuggestions().

Access functions:

QString | misspelledWord() const

### `[read-only]` position : const QPoint

This property holds the position of the context menu request, usually the mouse position where the context menu event was triggered.

Access functions:

QPoint | position() const

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

This property holds the selected text of the context menu request.

Access functions:

QString | selectedText() const

### `[read-only]` spellCheckerSuggestions : const QStringList

This property holds a list of suggested replacements for misspelledWord() if the menu context request is a word considered misspelled by the spell-checker.

Access functions:

QStringList | spellCheckerSuggestions() const

## Member Function Documentation

### `[virtual noexcept]` QWebEngineContextMenuRequest::~QWebEngineContextMenuRequest()

Destroys the context menu request.