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. QML and strophe.js

QML and strophe.js

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.2k 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.
  • C Offline
    C Offline
    croopie
    wrote on last edited by
    #1

    I'm experimenting using Strophe.js http://strophe.im/strophejs/ to get BOSH connection between my server and QML app (mostly because it would make HTML5<->QML porting reeeally easy in case of certain kind of apps that use BOSH). I have nothing else but a qml with import strophe.js as Strophe and there I try to var connection = new Strophe.Connection(myBoshServer) as told in strophe tutorial.

    Result is: TypeError: Result of expression 'Strophe.Connection' [undefined] is not a constructor.

    I have absolutely no idea why / what that means. Same stuff works perfectly as a HTML5 app.

    Any ideas? Thanks!

    Additional info from strophe.js:

    @/** Constructor: Strophe.Connection

    • Create and initialize a Strophe.Connection object.
    • Parameters:
    • (String) service - The BOSH service URL.
    • Returns:
    • A new Strophe.Connection object.
      */
      Strophe.Connection = function (service)
      {
      ...
      @

    edit: and here's the whole thing of beauty:

    @import QtQuick 1.1
    import "./strophe.js" as Strophe

    Rectangle {
    width: 640
    height: 360
    MouseArea {
    anchors.fill: parent
    onClicked: {
    var connection = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");
    }
    }
    }
    @

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

      Try changing:

      @var connection = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");@

      to

      @var connection = new Strophe.Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind");@

      When you import a js file all the variables and functions are given the namespace under the as ....

      Eg:

      @
      import "myjs.js" as myjs

      myjs.hello();
      @

      Read this for more info:

      http://doc.qt.nokia.com/4.7-snapshot/qdeclarativejavascript.html

      1 Reply Last reply
      0
      • C Offline
        C Offline
        croopie
        wrote on last edited by
        #3

        Thanks kbcool, that was the problem there of course! However it seems that the Strophe.js would require fair amount of tweaking to get it working with the QML so I gave up and search other way to do it.

        Thanks anyway!

        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