Answer the question
In order to leave comments, you need to log in
How to enable web notifications in QtWebEngine?
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
self.page = QWebEnginePage()
self.page.Notifications = True
self.page.setHtml(html)
messaging.requestPermission
Notification.permission
Answer the question
In order to leave comments, you need to log in
class WebEnginePage(QWebEnginePage):
def __init__(self, *args, **kwargs):
QWebEnginePage.__init__(self, *args, **kwargs)
self.featurePermissionRequested.connect(self.onFeaturePermissionRequested)
def onFeaturePermissionRequested(self, url, feature):
if feature == WebEnginePage.Notifications:
self.setFeaturePermission(url, feature, QWebEnginePage.PermissionGrantedByUser)
else:
self.setFeaturePermission(url, feature, QWebEnginePage.PermissionDeniedByUser)
view = QWebEngineView()
page = WebEnginePage()
view.setPage(page)
view.load(QUrl("https://"))
page.setHtml(html)
view.show()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question