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. Java Script failed to create QtQuick 2.5 object
Forum Updated to NodeBB v4.3 + New Features

Java Script failed to create QtQuick 2.5 object

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 1 Posters 853 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.
  • S Offline
    S Offline
    SandyMedical
    wrote on last edited by SandyMedical
    #1

    I am creating QT object in Java script & emitting signal from JavaScript to QML Slot.

    My work Environment : Qt 5.8 MSVC2015 64bit, Windows 7 64 bit.

    Java Script code :

    
       var internalQmlObject = **Qt.createQmlObject('import QtQuick 2.5; QtObject{ signal someSignal(int value) }', Qt.application, 'InternalQmlObject')**;
        function runNow(){
            internalQmlObject.someSignal(42);
        }
    

    Code of QML :

    import QtQuick 2.5
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.0
    import QtWebEngine 1.4
    import "testJava.js" as Helper
    
    
         ApplicationWindow {
            width: 1024
            height: 750
            visible: true
        
            WebEngineView {
                id: webEngine
                anchors.fill: parent
                url: "qrc:/TestPage.html"
        
                function someSlot(v) {
                    console.log("Signal received " + v);
                }
        
                onLoadingChanged: {
                    Helper.internalQmlObject.someSignal.connect(someSlot);
                }
            }
        }
    

    But Java Script failed to create QtQuick 2.5 object:

    Application log :
    D:\task\QT_Test\build-testURL-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug\testURL.exe...

    js: Uncaught ReferenceError: Qt is not defined

    [4492:5796:0427/113341:INFO:CONSOLE(1)] "Uncaught ReferenceError: Qt is not defined", source: qrc:/testJava.js (1)

    you can find my code

    Any suggestion why JavaScript failed to identify QT?

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

      you can find my code

      I found the issue, in HTML page, I am loading testJava.js, which causing this issue : <head> <script type="text/javascript" src="testJava.js"></script> </head>

      But still why it should have an issue ?

      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