qt - Qt WebEngine : gpu_process_transport_factory. cc(642) 错误] 切换到软件合成

标签 qt qml qtwebengine

背景

  • 平台:Windows 10
  • Qt 版本:5.12.1

我必须使用 QML QtWebKit 移植最初使用 Qt 4.7.4 完成的 QML 应用程序。这个 QML 非常简单,它只是显示本地 html。我读过this web page关于如何迁移 QtWebKit。

所以,经过几个小时的尝试错误后,我决定这样做 qt example .

当我尝试执行应用程序时,我有以下输出:

[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()
  1. 知道我做错了什么吗?
  2. 可以继续使用 QtWebKit 吗?
  3. QtWebEngine 是渲染简单 html 用户指南的最佳解决方案吗?

我的 QtWebEngine 代码:

#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();
}

Qt WebEngine QML

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"
    }
}

QtWebKit代码

rootContext()->setContextProperty("uiDataLayer", pUiDataLayer);
setSource(QUrl("qrc:/SCmainWindow/Resources/userGuide.qml"));
QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(rootObject());

QtWebKit Qml

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";
        }
    }

}

最佳答案

知道我做错了什么吗?

这些不是 Qt 的错误,而是 chromium 的错误,在许多情况下您必须忽略它们,在您的特定情况下,这表明应用程序尝试使用 GPU,但由于兼容性问题,它将使用 CPU(您应该获取这些错误)如果您从 CMD 运行 google chrome 并启用标志来进行调试,则会出现相同的错误)。

因此请避免这些错误,因为您提供的代码是正确的。

是否可以坚持使用 QtWebKit?

您可以继续使用Qt WebKit,但Qt没有官方支持,您必须手动编译它。该项目托管在https://github.com/qtwebkit/qtwebkit .

QtWebEngine 是渲染简单 html 用户指南的最佳解决方案吗?

“最好”是相对的,除非您指明了客观参数,可以让您在每种技术/替代方案中衡量自己。我可以向您指出的是,它是渲染使用 HTML、js 等的网页、html 等的官方选项。

关于qt - Qt WebEngine : gpu_process_transport_factory. cc(642) 错误] 切换到软件合成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59041792/

相关文章:

macos - QML Mac 全屏模式失去鼠标焦点

qt - QML 中的 'this' 关键字是什么

qt - 如何在 Windows 和 MSVC 2015 上构建 Qt 5.5 QtWebEngine

qt - 如何在运行时确定 QtWebEngine 在 Qt 5 中使用哪个 Chrome 版本?

c++ - Qt信号转发;继承QAbstractProxyModel

c++ - QT中的Q_OBJECT(对vtable xxx的 undefined reference )

c++ - 将大字符串的逗号分隔子字符串转换为 QML 中的变体数组元素

python - 如何使用 QWebEngineView 和 QUrl 下载 csv 文件

c++ - 从 QSqlTableModel 获取数据并放入 QVector<QPointF> 的最快方法

c++ - 如何每秒调用一个更新qt小部件的函数