Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QT Web Engine freezes when calling any method from main.cpp

QT Web Engine freezes when calling any method from main.cpp

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 859 Views
  • 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.
  • A Offline
    A Offline
    aphi
    wrote on last edited by
    #1

    Hello,
    now I have another problem. When I try to load another URL from main.cpp with the overload method, the whole application freezes and crashes. What am I doing wrong here? I have done the same like described in http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
    Code:
    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    #include <QtQuick/QtQuick>
    #include <QtWebView/QtWebView>
    #include <QtWebEngineWidgets/QWebEngineView>
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        //QtWebView::initialize();
    
    
        QQuickView view;
        view.setSource(QUrl("qrc:/main.qml"));
        view.show();
        QObject *object = view.rootObject();
        QQuickItem *item = qobject_cast<QQuickItem*>(object);
        QWebEngineView* rect = item->findChild<QWebEngineView*>("view");
    
        QVariant msg = "http://google.de";
        rect->setProperty("url","http://google.de");
    //or
    rect->load(QUrl("http://google.de"));
     
    
    
    
        return app.exec();
    }
    
    

    main.qml

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtWebEngine 1.0
    Item {
        visible: true
        width: 1500
        height: 800
       // title: qsTr("CENSORED")
        WebEngineView {
            id: view
            anchors.fill: parent
            url: "CENSORED"
    
            objectName: "view"
       
        }
    
    }
    
    
    A 1 Reply Last reply
    0
    • A aphi

      Hello,
      now I have another problem. When I try to load another URL from main.cpp with the overload method, the whole application freezes and crashes. What am I doing wrong here? I have done the same like described in http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
      Code:
      main.cpp

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QtQuick/QtQuick>
      #include <QtWebView/QtWebView>
      #include <QtWebEngineWidgets/QWebEngineView>
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
          //QtWebView::initialize();
      
      
          QQuickView view;
          view.setSource(QUrl("qrc:/main.qml"));
          view.show();
          QObject *object = view.rootObject();
          QQuickItem *item = qobject_cast<QQuickItem*>(object);
          QWebEngineView* rect = item->findChild<QWebEngineView*>("view");
      
          QVariant msg = "http://google.de";
          rect->setProperty("url","http://google.de");
      //or
      rect->load(QUrl("http://google.de"));
       
      
      
      
          return app.exec();
      }
      
      

      main.qml

      import QtQuick 2.6
      import QtQuick.Window 2.2
      import QtWebEngine 1.0
      Item {
          visible: true
          width: 1500
          height: 800
         // title: qsTr("CENSORED")
          WebEngineView {
              id: view
              anchors.fill: parent
              url: "CENSORED"
      
              objectName: "view"
         
          }
      
      }
      
      
      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @aphi QWebEngineView* rect = item->findChild<QWebEngineView*>("view"); you never test the result here. It can be null and if it was null it would crash.

      Can you run this in a debugger and give a backtrace of the crash?

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved