Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do i bind Class to QML window in Qt5 or is it a bug.
Forum Updated to NodeBB v4.3 + New Features

How do i bind Class to QML window in Qt5 or is it a bug.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.8k Views 1 Watching
  • 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.
  • 1 Offline
    1 Offline
    1roo
    wrote on last edited by
    #1

    Hi

    I create a QML window with
    @void Check::createWindow(){
    QDeclarativeView *decView= new QDeclarativeView();

        QObject::connect(decView->engine(), SIGNAL(quit()),decView, SLOT(deleteLater()));
    
        QString mUrl="http://www.google.com";
        decView->engine()->rootContext()->setContextProperty("MyApp",this);
        decView->engine()->rootContext()->setContextProperty("mUrl",mUrl);
        decView->setSource(QUrl("qrc:/inc/getwebsite.qml"));
       decView->show();
    

    }@

    my slot (public slot)
    @QString Check::getAndBlockSiteToCheck(){

    qDebug()<<"Getting site to check";
    return QString("http://www.asdf.com");
    

    }@

    and qml file
    @ import QtQuick 1.1
    import QtWebKit 1.0
    WebView {

        width:600
        height:700
        settings.javascriptEnabled: true
        settings.javascriptCanOpenWindows: true
        settings.developerExtrasEnabled : true
        settings.autoLoadImages: false
    
    
        javaScriptWindowObjects: QtObject {
                 WebView.windowObjectName: "MyCom"
    
                 function openNew(){
                          alert&#40;'old url '+webView.url&#41;;
                          var nexturl=MyApp.getAndBlockBlogToCheck(&#41;;
                         alert("next url is "+nexturl&#41;;
                     webView.url=nexturl;
    
    
                }
             }
    
    
    
        id: webView
        objectName: "myWebView"
         url:mUrl
    
    
        onLoadFinished: {webView.evaluateJavaScript("window.setTimeout('window.MyCom.openNew(&#41;',5000&#41;;");}
        onAlert: console.log(message);
    

    }@

    It runs first website (google.com) but when it tries to go to new page i get "exited with code -1073741819" error.
    I just installed newest Qt5 final.
    Where do i make mistake?

    1 Reply Last reply
    0
    • 1 Offline
      1 Offline
      1roo
      wrote on last edited by
      #2

      I was opening Check::createWindow() from another class without making instance of "Check".

      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