W3cubDocs

/Qt

ContextMenuRequest QML Type

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

Import Statement: import QtWebEngine
Since: QtWebEngine 1.4

Properties

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;
        myMenu.trigger.connect(view.triggerWebAction);
        myMenu.popup();
    }
    // ...
}

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.

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

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

Constant Description
ContextMenuRequest.CanUndo Undo is available.
ContextMenuRequest.CanRedo Redo is available.
ContextMenuRequest.CanCut Cut is available.
ContextMenuRequest.CanCopy Copy is available.
ContextMenuRequest.CanPaste Paste is available.
ContextMenuRequest.CanDelete Delete is available.
ContextMenuRequest.CanSelectAll Select All is available.
ContextMenuRequest.CanTranslate Translate is available.
ContextMenuRequest.CanEditRichly Context is richly editable.

This property was introduced in QtWebEngine 1.7.

[read-only] isContentEditable : bool

Indicates whether the selected web content is editable.

[read-only] linkText : string

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

[read-only] linkUrl : url

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

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

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

Constant Description
ContextMenuRequest.MediaInError An error occurred.
ContextMenuRequest.MediaPaused Media is paused.
ContextMenuRequest.MediaMuted Media is muted.
ContextMenuRequest.MediaLoop Media can be looped.
ContextMenuRequest.MediaCanSave Media can be saved.
ContextMenuRequest.MediaHasAudio Media has audio.
ContextMenuRequest.MediaCanToggleControls Media can show controls.
ContextMenuRequest.MediaControls Media controls are shown.
ContextMenuRequest.MediaCanPrint Media is printable.
ContextMenuRequest.MediaCanRotate Media is rotatable.

This property was introduced in QtWebEngine 1.7.

[read-only] mediaType : enumeration

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

Constant Description
ContextMenuRequest.MediaTypeNone Not a media.
ContextMenuRequest.MediaTypeImage An image.
ContextMenuRequest.MediaTypeVideo A video.
ContextMenuRequest.MediaTypeAudio An audio element.
ContextMenuRequest.MediaTypeCanvas A canvas.
ContextMenuRequest.MediaTypeFile A file.
ContextMenuRequest.MediaTypePlugin A plugin.

[read-only] mediaUrl : url

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

[read-only] misspelledWord : string

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

[read-only] position : point

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

[read-only] selectedText : string

The selected text the context menu was created for.

[read-only] spellCheckerSuggestions : stringlist

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

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qml-qtwebengine-contextmenurequest.html