Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

WebView does not load url



  • I'm trying a very simple test application on Raspberri Pi 3, with a Buildroot environment and Qt 5.12.5.

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QtWebView/QtWebView>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
        QtWebView::initialize();
    
        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();
    }
    

    main.qml

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtWebView 1.1
    
    Window {
        visible: true
        width: 640
        height: 480
    
        WebView {
            url: "http://www.google.it"
    
            onLoadProgressChanged: console.log(loadProgress)
            onLoadingChanged: console.log(loading)
        }
    }
    

    Here the output:

    # ./testWeb --no-sandbox
    QML debugging is enabled. Only use this in a safe environment.
    [0203/081353.795855:WARNING:resource_bundle_qt.cpp(116)] locale_file_path.empty() for locale 
    [0203/081353.906904:WARNING:resource_bundle_qt.cpp(116)] locale_file_path.empty() for locale
    

    The screen shows the blank window only.
    I don't think the warnings about the locale are critical to load an URL (anyway I'm trying to understand how to fix them).

    Any idea?
    Thanks in advance



  • Well, it was simple enough:

        anchors.fill: parent

Log in to reply