我在Qt 5.10.1中使用QWebEngineView有问题。当我右键单击页面中的"输入"字段时,上下文菜单中未显示"粘贴"操作。
这是我在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(( 它在某些情况下可以正常工作,例如,如果我选择文本,上下文菜单会正确显示"复制"或"取消选择"操作。
有人知道吗?
为了知识,我尝试了Qt 5.11.0(测试版(,这个版本解决了这个问题。