Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Javascript to qml

Javascript to qml

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 695 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.
  • W Offline
    W Offline
    wuzamarine
    wrote on last edited by
    #1

    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?

    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