Reputation: 46
I'm trying to use QWebEngineView
to create an interface with Python that will show a webpage that shows the progress of something (not relevant here).
The user should only be able to scroll (the page will always have a scroll bar). The user should not be able to click anything on the webpage.
I tried to set the browser as disabled:
self.browser = QWebEngineView(self)
self.browser.load(QUrl(URL))
self.browser.setZoomFactor(0.65)
self.browser.setDisabled(True)
self.layWeb.addWidget(self.browser)
It worked so that you can't click, but it also deactivated the scroll bar.
I also tried something like this:
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.browser = QWebEngineView()
self.browser.load(QUrl("https://stackoverflow.com/questions/66418148/pyqt-embed-qwebengineview-in-main-window"))
self.browser.setZoomFactor(0.65)
self.setCentralWidget(self.browser)
self.browser.focusProxy().installEventFilter(self)
def eventFilter(self, obj, event):
if obj is self.browser.focusProxy() and event.type() != event.MouseButtonPress:
print("Widget click")
return super(MainWindow, self).eventFilter(obj, event)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
But I don't know how to handle the events. So how can I a QWebEngineView
as not clickable while still allowing scrolling?
Upvotes: 0
Views: 39