Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 577
Mitch Avatar asked May 16 '19 01:05

Mitch


1 Answers

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 ...

like image 180
harmv Avatar answered Oct 22 '22 18:10

harmv