如何在 Qt Creator 中编辑 QtWebKit 的右键上下文菜单?

发布于 2024-09-11 06:28:39 字数 335 浏览 9 评论 0原文

好吧,这是我的困境。我正在使用 Qt Creator 制作一个使用 Webkit 的简单应用程序。我认为 Qt Creator 会有一种简单的方法来使用信号和槽编辑器编辑右键单击上下文菜单,但事实证明这不是真的。我知道 webkit 有与上下文菜单有关的类,但我不知道如何通过 Qt Creator 访问它们。

我需要编辑上下文菜单的“在新窗口中打开链接”部分,以便在单击链接时在新窗口中打开我的应用程序,但正如我之前所说,我想不出一种编辑方法它没有从源代码编译修改后的 QtWebKit,这将是一个痛苦。

任何答案将不胜感激,如果它有任何区别,我主要是一名 C#/.NET 开发人员,并且我刚刚开始使用 Qt 和 C++。

Alright, here's my dillema. I am making a simple application with Qt Creator that makes use of Webkit. I thought Qt Creator would have an easy way to edit the right-click context menu with the signals and slots editor, but this has proven to not be true. I know webkit has classes that have to do with the context menu, but I don't know how to access them through Qt Creator.

I need to edit the "Open Link in New Window" part of the context menu so that it opens my application up in a new window when a link is followed, but as I said previously, I can't think of a way to edit it without compiling a modified QtWebKit from source, which would be a pain.

Any answers would be appreciated, and if it makes any difference, I'm mainly a C#/.NET developer, and I've jsut started working with Qt and C++.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戴着白色围巾的女孩 2024-09-18 06:28:39

QWidget::contextMenuEvent( QContextMenuEvent * event ) 是一个“虚拟保护”函数。
您可以继承QWebView,然后重写“contextMenuEvent”。

The QWidget::contextMenuEvent( QContextMenuEvent * event ) is a "virtual protected" function.
You can inherit the QWebView, and then override "contextMenuEvent".

迷爱 2024-09-18 06:28:39

如果您需要的只是处理“在新窗口中打开”操作,我建议重新实现虚拟保护的 QWebView::createWindow。如果不使用 createStandardContextMenu,从头开始重新实现 contextMenuEvent 可能会很复杂,因为 createStandardContextMenu 会将“在新窗口中打开”定向到 createWindow。

If what you need is just to handle "Open in New Window" action, I suggest to reimplement virtual protected QWebView::createWindow. Reimplementing contextMenuEvent from scratch could be complicated without using createStandardContextMenu, which directs "Open in New Window" to createWindow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文