Right-clicking on any text on a webpage viewed with QWebView on Windows selects the word under the cursor. I want to disable this behaviour, but can’t find any reference in the docs.
Right-clicking on any text on a webpage viewed with QWebView on Windows selects the
Share
This preference looks to be deep into Webkit (the engine that powers
QWebViewand Google Chrome among many others). There is a Webkit bug that involves a bit of discussion around the desired behaviour on right-clicking some text, but this discussion (and subsequent changes) occurred after Webkit was branched to create QtWebkitRelease20 (the version released with Qt 4.7.x) – I think this is why the behaviour you want is visible in Chrome but not Qt. There is another upcoming branch, QtWebkitRelease22, which will be included as part of Qt 4.8 – I think the change you’re after will be implemented in that release.So your options as I see them are either:
QWidget::setContextMenuPolicy(Qt::NoContextMenu)will do the job if so.QWebView::selectionChanged()signaland then usefindText("")to force a deselection.