ContextMenuRequest QML Type

A request for showing a context menu. More...

Import Statement: import QtWebEngine
Since: QtWebEngine 1.4


Detailed Description

A ContextMenuRequest is passed as an argument of the WebEngineView::contextMenuRequested signal. It provides further information about the context of the request. The position property provides the origin of the request.

The accepted property of the request indicates whether the request is handled by the user code or the default context menu should be displayed.

The following code uses a custom menu to handle the request:

WebEngineView {
    id: view
    // ...
    onContextMenuRequested: function(request) {
        request.accepted = true;
        myMenu.x = request.x;
        myMenu.y = request.y;
    // ...

Property Documentation

accepted : bool

Indicates whether the context menu request has been handled by the signal handler.

If the property is false after any signal handlers for WebEngineView::contextMenuRequested have been executed, a default context menu will be shown. To prevent this, set request.accepted to true.

The default is false.

Note: The default content of the context menu depends on the web element for which the request was actually generated.

editFlags : flags [read-only, since QtWebEngine 1.7]

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

ContextMenuRequest.CanUndoUndo is available.
ContextMenuRequest.CanRedoRedo is available.
ContextMenuRequest.CanCutCut is available.
ContextMenuRequest.CanCopyCopy is available.
ContextMenuRequest.CanPastePaste is available.
ContextMenuRequest.CanDeleteDelete is available.
ContextMenuRequest.CanSelectAllSelect All is available.
ContextMenuRequest.CanTranslateTranslate is available.
ContextMenuRequest.CanEditRichlyContext is richly editable.

This property was introduced in QtWebEngine 1.7.

isContentEditable : bool [read-only]

Indicates whether the selected web content is editable.

linkText : string [read-only]

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

linkUrl : url [read-only]

The URL of the link if the selected web page content is a link. It is not guaranteed to be a valid URL.

mediaFlags : flags [read-only, since QtWebEngine 1.7]

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

ContextMenuRequest.MediaInErrorAn error occurred.
ContextMenuRequest.MediaPausedMedia is paused.
ContextMenuRequest.MediaMutedMedia is muted.
ContextMenuRequest.MediaLoopMedia can be looped.
ContextMenuRequest.MediaCanSaveMedia can be saved.
ContextMenuRequest.MediaHasAudioMedia has audio.
ContextMenuRequest.MediaCanToggleControlsMedia can show controls.
ContextMenuRequest.MediaControlsMedia controls are shown.
ContextMenuRequest.MediaCanPrintMedia is printable.
ContextMenuRequest.MediaCanRotateMedia is rotatable.

This property was introduced in QtWebEngine 1.7.

mediaType : enumeration [read-only]

The type of the media element or MediaTypeNone if the selected web page content is not a media element.

ContextMenuRequest.MediaTypeNoneNot a media.
ContextMenuRequest.MediaTypeImageAn image.
ContextMenuRequest.MediaTypeVideoA video.
ContextMenuRequest.MediaTypeAudioAn audio element.
ContextMenuRequest.MediaTypeCanvasA canvas.
ContextMenuRequest.MediaTypeFileA file.
ContextMenuRequest.MediaTypePluginA plugin.

mediaUrl : url [read-only]

The URL of media if the selected web content is a media element.

misspelledWord : string [read-only]

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

position : point [read-only]

The position of the user action from where the context menu request originates.

selectedText : string [read-only]

The selected text the context menu was created for.

spellCheckerSuggestions : stringlist [read-only]

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

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.