inizialize
-
I have this error in my app.
QtWebEngine::initialize() must be called after the construction of the application object.
But I have put intialize after .. Whay this ?
@elicat
https://doc.qt.io/qt-5/qtwebengine.html#initialize states:Sets up an OpenGL Context that can be shared between threads. This has to be done before QGuiApplication is created and before window's QPlatformOpenGLContext is created.
So I don't know about the error message, but the docs state before, and that's where I do mine. Try swapping the order!?
-
@JonB said in inizialize:
So I don't know about the error message, but the docs state before, and that's where I do mine. Try swapping the order!?
I have try several times. the result it's same
@elicat
Hmm. I don't even use that function. Are you using Qt Quck, or just standard widgets? Because that doc above sates:Helper functions for the Qt WebEngine (Qt Quick) module
? Because all I do (I'm afraid I'm Python/PyQt5) is:
# next line required to avoid # "QtWebEngineWidgets must be imported before a QCoreApplication instance is created", or related problem try: from PyQt5.QtWebEngineWidgets import QWebEngineView except: pass # create the QGuiApplication app = QtWidgets.QApplication(sys.argv)
-
@JonB said in inizialize:
Hmm. I don't even use that function. Are you using Qt Quck, or just standard widgets? Because that doc above sates:
I don't use widgets. For My project i use QML and inside I set webengine e dynamic url.
I use QT Tools Into VisualStudio Comunity 2017 -
@JonB said in inizialize:
Hmm. I don't even use that function. Are you using Qt Quck, or just standard widgets? Because that doc above sates:
I don't use widgets. For My project i use QML and inside I set webengine e dynamic url.
I use QT Tools Into VisualStudio Comunity 2017 -
Thanks, however the problem is not the QML but the initialization command.
I hope resolve it quickly -
Thanks, however the problem is not the QML but the initialization command.
I hope resolve it quickly@elicat
OK, did you try Googling forQML QWebEngine...
? Because there is an example I see at https://doc.qt.io/qt-5/qml-qtwebengine-webengineview.html:Initializing Web Engine
For the web engine view to be rendered, the web engine must be initialized by using QtWebEngine::initialize in the application main source file, as illustrated by the following code snippet:
int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QtWebEngine::initialize(); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
As I originally suggested, it seems to call the
initialize()
before theQGuiApplication()
. Try the above code, at least to see whether you get the error you report? -
@JonB said in inizialize:
As I originally suggested, it seems to call the initialize() before the QGuiApplication(). Try the above code, at least to see whether you get the error you report?
My code it's same this.
I have two strange things.
- The QtWebEngine class is recognized but not highlighted as a class
- if I delete the initialization line the application starts and works
Obviously it's not a correct thing and it's clear so I'm trying to understand
-
@JonB said in inizialize:
As I originally suggested, it seems to call the initialize() before the QGuiApplication(). Try the above code, at least to see whether you get the error you report?
My code it's same this.
I have two strange things.
- The QtWebEngine class is recognized but not highlighted as a class
- if I delete the initialization line the application starts and works
Obviously it's not a correct thing and it's clear so I'm trying to understand
@elicat Nobody have idea?
If I insert the initialization line, before or after "QGuiApplication app", the error is reported to me (see previous post), why?
If I delete the webengine initialization line the program works (in QT 511.1), why is this possible?