QWebEngineView 在 Qt 5.10.1 的 "input" 字段上没有粘贴上下文菜单
QWebEngineView No Paste context menus on "input" fields in Qt 5.10.1
我对 Qt 5.10.1 中的 QWebEngineView 有疑问。
当我右键单击页面中的 "input" 字段时,"Paste" 操作未显示在上下文菜单中。
这是我在 contextMenuEvent 上的代码:
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = page()->createStandardContextMenu();
const QList<QAction*> actions = menu->actions();
auto it = std::find(actions.cbegin(), actions.cend(), page()->action(QWebEnginePage::ViewSource));
if (it != actions.cend()) {
(*it)->setVisible(false);
}
menu->popup(event->globalPos());
}
createStandardContextMenu() 它在某些情况下可以正常工作,例如,如果我 select 文本,上下文菜单会正确显示 "Copy" 或 "Unselect" 操作。
有人知道吗?
为了知识,我尝试了 Qt 5.11.0 (beta),这个版本解决了这个问题。
我对 Qt 5.10.1 中的 QWebEngineView 有疑问。 当我右键单击页面中的 "input" 字段时,"Paste" 操作未显示在上下文菜单中。
这是我在 contextMenuEvent 上的代码:
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = page()->createStandardContextMenu();
const QList<QAction*> actions = menu->actions();
auto it = std::find(actions.cbegin(), actions.cend(), page()->action(QWebEnginePage::ViewSource));
if (it != actions.cend()) {
(*it)->setVisible(false);
}
menu->popup(event->globalPos());
}
createStandardContextMenu() 它在某些情况下可以正常工作,例如,如果我 select 文本,上下文菜单会正确显示 "Copy" 或 "Unselect" 操作。
有人知道吗?
为了知识,我尝试了 Qt 5.11.0 (beta),这个版本解决了这个问题。