Search code examples
pythonpyside2qtwebengine

Qt WebEngine seems to be initialized


When I run my Qt application I get the message

Qt WebEngine seems to be initialized from a plugin. Please set Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before constructing QGuiApplication.

The app runs fine regardless of the fact that this is getting dumped to the terminal. I cant seem to find the root cause or really understand what this message is trying to tell me. What is this message saying and how can I fix it?


Solution

  • This can be fixed by setting AA_ShareOpenGLContexts before Spawning the QApplication.

    See below an example when using PySide2

      from PySide2 import QtCore, QtWidgets
    
      if __name__ == '__main__':
          QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
          qt_app = QtWidgets.QApplication(sys.argv)
    

    NB: As mentioned as reply in the question: When using PyQt5, checkout https://bugreports.qt.io/browse/QTBUG-51379 instead ...