Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved WebView does not load url

    Qt WebKit
    1
    2
    231
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mark81 last edited by Mark81

      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

      1 Reply Last reply Reply Quote 0
      • M
        Mark81 last edited by

        Well, it was simple enough:

            anchors.fill: parent
        
        1 Reply Last reply Reply Quote 1
        • First post
          Last post