1

I want to compile and run WebEngine Recipe Browser Example with Qt-6.2.3 or Qt_6_4_0 but I get this error:

QML debugging is enabled. Only use this in a safe environment.
qt.webenginecontext: 

GLImplementation: desktop
Surface Type: OpenGL
Surface Profile: CompatibilityProfile
Surface Version: 4.6
Using Default SG Backend: yes
Using Software Dynamic GL: no
Using Angle: no

Init Parameters:
  *  application-name recipebrowser 
  *  browser-subprocess-path /home/parisa/Applications/Qt/6.2.3/gcc_64/libexec/QtWebEngineProcess 
  *  create-default-gl-context  
  *  disable-features DnsOverHttpsUpgrade,ConsolidatedMovementXY,InstalledApp,BackgroundFetch,WebOTP,WebPayments,WebUSB,PictureInPicture 
  *  disable-setuid-sandbox  
  *  disable-speech-api  
  *  enable-features NetworkServiceInProcess,TracingServiceInProcess 
  *  enable-threaded-compositing  
  *  gpu-preferences UAAAAAAAAAAoAAAQAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= 
  *  in-process-gpu  
  *  use-gl desktop 

and I see this result:

enter image description here

web pages (html content ) can't load from qrc (Resource file).

But as I Build and Run this example in Qt-5.15.2 it runs correctly.

enter image description here

The only difference between these two versions and examples is that Qt-5.15.2 uses QtWebEngine but in Qt-6.2.3 or Qt_6_4_0 they use QtWebEngineQuick.

I dont know how should I fix this issue and use QtWebEngineQuick.

I test QtWebEngineQuick and this issue will happen when I want to load any HTML file (even simple) from Resource , but if I choose url from web like https://stackoverflow.com it works correctly.

for example, if I want to Run this Example I got that Error!

in main.cpp

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtWebEngineQuick/qtwebenginequickglobal.h>


int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QtWebEngineQuick::initialize();

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);

    return app.exec();
}

in main.qml

import QtQuick
import QtQuick.Window
import QtWebEngine

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    WebEngineView {
        id: webView
        anchors.fill: parent
        url: "qrc:/index.html"
    }
}

in index.html

<html>
 <head>
 </head>
 <body>
   <h1>Hello World<h1>
 </body>
</html>

error output picture:

enter image description here

I use Ubuntu 20.04 and NVIDIA 470 GPU. I don't understand why this happens and how can I fix it.

4
  • Why don't you use a relative reference. Since both main.qml and index.html are at the same hierarchy. Then you should only need to specify url: "index.html" Commented Sep 29, 2022 at 23:00
  • @StephenQuan Thanks for your comment but It didnt work, the problem is to load the pages from the file. I also tested "url: "index.html" too, but it didn't matter I have trouble even running Qt example ( WebEngine Recipe Browser) and the pages are not loaded Commented Sep 30, 2022 at 3:00
  • @Parisa.H.R try "qrc:///..." I did not test it but just a blind guess Commented Oct 21, 2022 at 6:21
  • @SoheilArmin Thanks for your comment but It didn't work, I try "qrc:///index.html", "index.html" and "qrc:/index.html" but in all of them, they can't load files. I have trouble even running the Qt example ( WebEngine Recipe Browser) and pages are not loading in that example, it uses "qrc:///pages/pizza.html" Commented Oct 21, 2022 at 11:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.