Capturing mouse events for specific dom/web elements in QT
- by Red Serpent
Hi
I would like to know if it is possible in QTWebKit to install an event filter or capture events that occur from specific Dom elements. For example, my webview is showing a webpage that has text, images and an edit box, I want to disable the right-clicking and highlighting functionality on the text and images but at the same time when the user right-clicks inside the edit box, I want to display my context menu.
I am not sure where should I install my event filter, in QwebView or QwebPage... currently this is what I'm using:
MainWindow::MainWindow()
{
centralWidget = new WebView(this);
setCentralWidget(centralWidget);
centralWidget->webView->installEventFilter(this);
//No mouse events are rising on QWebPage
//centralWidget->webView->page()->installEventFilter(this);
}
As its clear in the code above, when installing an EventFilter on QwebPage, I never receive any QMouseEvents, not by moving clicking or releasing any mouse buttons. While when setting it to filter events from QWebView it works fine.
I am really interested with the first part of my question as to how handle Dom elements differently.
How can I achieve such goal?
Regards