QWebEngineContextMenuData Class

The QWebEngineContextMenuData class provides context data for populating or extending a context menu with actions. More...

Header: #include <QWebEngineContextMenuData>
qmake: QT += webenginewidgets
Since: Qt 5.7

This class was introduced in Qt 5.7.

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 }

Public Functions

QWebEngineContextMenuData(const QWebEngineContextMenuData &other)
QWebEngineContextMenuData()
QWebEngineContextMenuData &operator=(const QWebEngineContextMenuData &other)
~QWebEngineContextMenuData()
QWebEngineContextMenuData::EditFlags editFlags() const
bool isContentEditable() const
bool isValid() const
QString linkText() const
QUrl linkUrl() const
QWebEngineContextMenuData::MediaFlags mediaFlags() const
QWebEngineContextMenuData::MediaType mediaType() const
QUrl mediaUrl() const
QString misspelledWord() const
QPoint position() const
QString selectedText() const
QStringList spellCheckerSuggestions() const

Detailed Description

QWebEngineContextMenuData is returned by QWebEnginePage::contextMenuData() 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

enum QWebEngineContextMenuData::EditFlag
flags QWebEngineContextMenuData::EditFlags

The available edit operations in the current context.

ConstantValueDescription
QWebEngineContextMenuData::CanUndo0x1Undo is available.
QWebEngineContextMenuData::CanRedo0x2Redo is available.
QWebEngineContextMenuData::CanCut0x4Cut is available.
QWebEngineContextMenuData::CanCopy0x8Copy is available.
QWebEngineContextMenuData::CanPaste0x10Paste is available.
QWebEngineContextMenuData::CanDelete0x20Delete is available.
QWebEngineContextMenuData::CanSelectAll0x40Select All is available.
QWebEngineContextMenuData::CanTranslate0x80Translate is available.
QWebEngineContextMenuData::CanEditRichly0x100Context is richly editable.

This enum was introduced or modified in Qt 5.11.

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

enum QWebEngineContextMenuData::MediaFlag
flags QWebEngineContextMenuData::MediaFlags

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

ConstantValueDescription
QWebEngineContextMenuData::MediaInError0x1An error occurred.
QWebEngineContextMenuData::MediaPaused0x2Media is paused.
QWebEngineContextMenuData::MediaMuted0x4Media is muted.
QWebEngineContextMenuData::MediaLoop0x8Media can be looped.
QWebEngineContextMenuData::MediaCanSave0x10Media can be saved.
QWebEngineContextMenuData::MediaHasAudio0x20Media has audio.
QWebEngineContextMenuData::MediaCanToggleControls0x40Media can show controls.
QWebEngineContextMenuData::MediaControls0x80Media controls are shown.
QWebEngineContextMenuData::MediaCanPrint0x100Media is printable.
QWebEngineContextMenuData::MediaCanRotate0x200Media is rotatable.

This enum was introduced or modified in Qt 5.11.

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

enum QWebEngineContextMenuData::MediaType

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

ConstantValueDescription
QWebEngineContextMenuData::MediaTypeNone0The context is not a media type.
QWebEngineContextMenuData::MediaTypeImage1The context is an image element.
QWebEngineContextMenuData::MediaTypeVideo2The context is a video element.
QWebEngineContextMenuData::MediaTypeAudio3The context is an audio element.
QWebEngineContextMenuData::MediaTypeCanvas4The context is a canvas element.
QWebEngineContextMenuData::MediaTypeFile5The context is a file.
QWebEngineContextMenuData::MediaTypePlugin6The context is a plugin element.

Member Function Documentation

QWebEngineContextMenuData::QWebEngineContextMenuData(const QWebEngineContextMenuData &other)

Constructs context menu data from other.

QWebEngineContextMenuData::QWebEngineContextMenuData()

Constructs null context menu data.

QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextMenuData &other)

Assigns the other context menu data to this.

QWebEngineContextMenuData::~QWebEngineContextMenuData()

Destroys the context menu data.

QWebEngineContextMenuData::EditFlags QWebEngineContextMenuData::editFlags() const

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

bool QWebEngineContextMenuData::isContentEditable() const

Returns true if the content is editable by the user; otherwise returns false.

bool QWebEngineContextMenuData::isValid() const

Returns true if the context data is valid; otherwise returns false.

QString QWebEngineContextMenuData::linkText() const

Returns the text of a link if the context is a link.

QUrl QWebEngineContextMenuData::linkUrl() const

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

QWebEngineContextMenuData::MediaFlags QWebEngineContextMenuData::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.

QWebEngineContextMenuData::MediaType QWebEngineContextMenuData::mediaType() const

Returns the type of the media element or MediaTypeNone if the context is not a media element.

QUrl QWebEngineContextMenuData::mediaUrl() const

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

QString QWebEngineContextMenuData::misspelledWord() const

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

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

This function was introduced in Qt 5.8.

QPoint QWebEngineContextMenuData::position() const

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

QString QWebEngineContextMenuData::selectedText() const

Returns the selected text of the context.

QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const

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

This function was introduced in Qt 5.8.