A request for showing a context menu. 更多...
import 语句: | import QtWebEngine 1.8 |
Since: | QtWebEngine 1.4 |
A ContextMenuRequest is passed as an argument of the WebEngineView::contextMenuRequested signal. It provides further information about the context of the request. The position of the request origin can be found via the x and y 特性。
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(); } // ... }
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
.
默认为
false
.
注意: The default content of the context menu depends on the web element for which the request was actually generated.
The available edit operations in the current context or
CanDoNone
如果没有动作可用。
常量 | 描述 |
---|---|
ContextMenuRequest.CanUndo
|
撤销可用。 |
ContextMenuRequest.CanRedo
|
重做是可用的。 |
ContextMenuRequest.CanCut
|
剪切可用。 |
ContextMenuRequest.CanCopy
|
拷贝可用。 |
ContextMenuRequest.CanPaste
|
粘贴可用。 |
ContextMenuRequest.CanDelete
|
删除可用。 |
ContextMenuRequest.CanSelectAll
|
选择所有可用。 |
ContextMenuRequest.CanTranslate
|
翻译可用。 |
ContextMenuRequest.CanEditRichly
|
上下文富可编辑。 |
该特性在 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.
当前媒体元素的状态及其可用操作。
MediaNone
若选中网页内容不是媒体元素。
常量 | 描述 |
---|---|
ContextMenuRequest.MediaInError
|
出现错误。 |
ContextMenuRequest.MediaPaused
|
媒体被暂停。 |
ContextMenuRequest.MediaMuted
|
媒体被静音。 |
ContextMenuRequest.MediaLoop
|
媒体可以循环。 |
ContextMenuRequest.MediaCanSave
|
媒体可以被保存。 |
ContextMenuRequest.MediaHasAudio
|
媒体有音频。 |
ContextMenuRequest.MediaCanToggleControls
|
媒体可以展示控件。 |
ContextMenuRequest.MediaControls
|
媒体控件被展示。 |
ContextMenuRequest.MediaCanPrint
|
媒体可打印。 |
ContextMenuRequest.MediaCanRotate
|
媒体可旋转。 |
该特性在 QtWebEngine 1.7 引入。
[read-only] mediaType : enumeration |
The type of the media element or
MediaTypeNone
若选中网页内容不是媒体元素。
常量 | 描述 |
---|---|
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 |
若上下文是由拼写检查器认为的拼写错误单词,返回拼写错误单词。
[read-only] selectedText : string |
The selected text the context menu was created for.
If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements.
[read-only] x : int |
The x coordinate of the user action from where the context menu request originates.
[read-only] y : int |
The y coordinate of the user action from where the context menu request originates.