Reputation: 1039
I have to port a QML application that was initially done with Qt 4.7.4, using QML QtWebKit. This QML was pretty straightforward, it was just showing a local html. I read this web page on how to migrate QtWebKit.
So, after a couple of hours try an errors, I decided to do this qt example.
When I try to execute the application, I have this output :
[23912:5200:1125/182313.354:ERROR:gpu_process_transport_factory.cc(642)] Switching to software compositing.
[23912:5200:1125/182313.355:WARNING:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
[23912:5836:1125/182313.911:WARNING:gpu_process_host.cc(583)] !GpuDataManagerImpl::GpuProcessStartAllowed()
[23912:5836:1125/182329.059:WARNING:gpu_process_host.cc(583)] !GpuDataManagerImpl::GpuProcessStartAllowed()
#include <QtGui/QGuiApplication>
#include <QTQml/QQmlApplicationEngine>
#include <QTWebEngine/qtwebengineglobal.h>
int main(int argc, char *argv[])
{
QCoreApplication::setOrganizationName("QtExamples");
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QtWebEngine::initialize();
engine.load(QUrl(QStringLiteral("qrc:/test/Resources/main.qml")));
return app.exec();
}
import QtQuick 2.0
import QtQuick.Window 2.0
import QtWebEngine 1.0
Window {
width: 1024
height: 750
visible: true
WebEngineView {
anchors.fill: parent
url: "https://www.qt.io"
}
}
rootContext()->setContextProperty("uiDataLayer", pUiDataLayer);
setSource(QUrl("qrc:/SCmainWindow/Resources/userGuide.qml"));
QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(rootObject());
import QtQuick 1.1
import QtWebEngine 1.0
Rectangle {
id: userGuide
width: uiDataLayer.getUserGuideWindowWidth();
height: uiDataLayer.getUserGuideWindowHeight();
Flickable {
id: flickableWebView
anchors.fill: userGuide;
contentWidth: webView.width
contentHeight: webView.height
interactive: true
clip: true
WebEngineView {
id: webView
url : "file:///C:/SVN/products/faa_mx/vs2017.install2/install/MSVC10.0.x86.debug/lexix_verbyx/bin/win32/Lexis-UG-1.0-00.html";
}
}
}
Upvotes: 2
Views: 786
Reputation: 244112
Any idea what I am doing wrong?
Those are not errors of Qt but of chromium that you must ignore them in many of the cases that in your particular case indicates that the application tries to use the GPU but for compatibility problems it will use the CPU (You should get those same errors if you run google chrome from the CMD and enable the flags to get the debug).
So obviate those errors since the code you provide is correct.
Would it be possible to stick with QtWebKit?
You can continue using Qt WebKit but there is no official support from Qt, you must compile it manually. The project is hosted in https://github.com/qtwebkit/qtwebkit.
Is QtWebEngine is the best solution just to render a simple html user guide?
The "best" is relative unless you indicate objective parameters that allow you to measure yourself in each technology / alternative. What I can point out to you is that it is the official option to render web pages, html, etc. that use HTML, js, etc.
Upvotes: 3