- Qt 6.6
- Qt WebEngine
- C++ Classes
- QtWebEngineCore
- QWebEngineContextMenuRequest
- Qt 6.6.1 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

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

## Properties

- accepted : bool

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

## Member Function Documentation

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

Destroys the context menu request.

### QWebEngineContextMenuRequest::EditFlags QWebEngineContextMenuRequest::editFlags() const

Returns the available edit operations in the current context or `CanDoNone` if no actions are available.

Note: Getter function for property editFlags.

### bool QWebEngineContextMenuRequest::isContentEditable() const

Returns `true` if the context menu request is editable by the user; otherwise returns `false`.

Note: Getter function for property isContentEditable.

### QString QWebEngineContextMenuRequest::linkText() const

Returns the text of a link if the context menu request was requested for a link.

Note: Getter function for property linkText.

### QUrl QWebEngineContextMenuRequest::linkUrl() const

Returns the URL of a link if the menu context request is a link. It is not guaranteed to be a valid URL.

Note: Getter function for property linkUrl.

### QWebEngineContextMenuRequest::MediaFlags QWebEngineContextMenuRequest::mediaFlags() const

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

Note: Getter function for property mediaFlags.

### QWebEngineContextMenuRequest::MediaType QWebEngineContextMenuRequest::mediaType() const

Returns the type of the media element or `MediaTypeNone` if the context menu requestis not a media element.

Note: Getter function for property mediaType.

### QUrl QWebEngineContextMenuRequest::mediaUrl() const

If the context menu request is a media element, returns the URL of that media.

Note: Getter function for property mediaUrl.

### QString QWebEngineContextMenuRequest::misspelledWord() const

If the menu context request is a word considered misspelled by the spell-checker, returns the misspelled word.

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

Note: Getter function for property misspelledWord.

### QPoint QWebEngineContextMenuRequest::position() const

Returns the position of the context menu request, usually the mouse position where the context menu event was triggered.

Note: Getter function for property position.

### QString QWebEngineContextMenuRequest::selectedText() const

Returns the selected text of the context menu request.

Note: Getter function for property selectedText.

### QStringList QWebEngineContextMenuRequest::spellCheckerSuggestions() const

If the menu context request is a word considered misspelled by the spell-checker, returns a list of suggested replacements for misspelledWord().

Note: Getter function for property spellCheckerSuggestions.