Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

javascript to qml

$
0
0
I have a javascript script that works fine but I need it to work fine within Qt. Original ‘working’ JS script: var pusher = new Pusher("cb65d0a7a72cd94adf1f"); var channel = pusher.subscribe("ticker.155"); channel.bind("message", function(data) {         //console.log(data);         var topbuy = data.trade.topbuy;         var topsell = data.trade.topsell;         console.log("Buy Price: ", topbuy.price,                 "Buy Quantity:", topbuy.quantity),         console.log("Sell Price: ", topsell.price,                 "Sell Quantity:", topsell.quantity); }); But when I try and implement the code into QML, I start getting errors as though QML does not understand the code (constructor/event) Error: Starting C:\Qt\Qt5.3.1\5.3\mingw482_32\bin\qmlscene.exe… file:///C:/Qt5/Tools/QtCreator/bin/projects/echoQML/pusherScript.js:2: ReferenceError: Pusher is not defined echoQML.qml: import QtQuick 2.2 import "pusherScript.js" as Pusherscript Connections{ signal send (string notice) } pusherScript.js: Qt.include("pusher.min.js") var pusher = new Pusher("cb65d0a7a72cd94adf1f");  //this is the line it chokes on var channel = pusher.subscribe("ticker.155"); channel.bind("message", function(data) {         //console.log(data);         var topbuy = data.trade.topbuy;         var topsell = data.trade.topsell;         console.log("Buy Price: ", topbuy.price,                 "Buy Quantity:", topbuy.quantity),         console.log("Sell Price: ", topsell.price,                 "Sell Quantity:", topsell.quantity); }); How do I properly integrate this script into Qt?

Viewing all articles
Browse latest Browse all 4972

Trending Articles