PyQt QWebEngineView black flicker when tooltip of context menu comes up

82 Views Asked by At

My PyQtWebEngineView is randomly flickering black(i think it has to do with context menus and tooltips)

Try it yourseft:

import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings


class UiBrowser(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.browser = QWebEngineView(self)
        self.browser.setUrl(QtCore.QUrl("https://www.google.com"))
        self.browser.settings().setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True)

        self.initUI()

    def initUI(self):
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self.browser)

    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_F11:
            self.toggleFullScreen()

    def toggleFullScreen(self):
        if self.isFullScreen():
            self.showNormal()
        else:
            self.showFullScreen()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()
    window.setWindowTitle("Minimal Web Browser")
    browser_widget = UiBrowser()
    window.setCentralWidget(browser_widget)
    window.showFullScreen()
    sys.exit(app.exec_())

heres a video from the original code:

https://youtu.be/OrSx2awx4Lg(i had to record it with my phone because OBS wasn't working) If you run the given code you will see the same results.

0

There are 0 best solutions below