3

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++.

JC Leyba
  • 502
  • 3
  • 7
  • 17

2 Answers2

2

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

S. Razi
  • 378
  • 2
  • 8
1

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.

jichi
  • 6,333
  • 1
  • 31
  • 25