Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Qt on BlackBerry and QNX
  4. Problems importing another JavaScript library into QML
Forum Updated to NodeBB v4.3 + New Features

Problems importing another JavaScript library into QML

Scheduled Pinned Locked Moved Qt on BlackBerry and QNX
4 Posts 2 Posters 2.9k 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
    sawrubh
    wrote on 28 Dec 2012, 08:53 last edited by
    #1

    I am working in Cascades/QML and am using JavaScript for handling my application logic. I have this external javascript library (a .js file) located inside the assets, so I do something like this

    @import "libname.js" as Library@

    and the library was designed such that it defined a global object like :

    @LibGlobalObject = function (param) {
    //Some action
    };@

    and then it keeps adding methods by doing something like

    @GoodLib.prototype.methodOne = function(param) { };
    GoodLib.prototype.methodTwo = function(param) { };@

    and it says it can be used by doing something like :

    @(new GoodLib(someParam)).methodOne(new GoodLib(someParam));
    (new GoodLib(someParam)).methodTwo(new GoodLib(someParam));@

    so I thought of doing something like

    @(new Library.GoodLib(someParam)).methodOne(new Library.GoodLib(someParam));
    (new Library.GoodLib(someParam)).methodOne(new Library.GoodLib(someParam));@

    in my QML but it doesn't work.

    Can anyone tell me what it is that I'm doing wrong here ?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      daliusd
      wrote on 28 Dec 2012, 11:49 last edited by
      #2

      What is GoodLib?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sawrubh
        wrote on 28 Dec 2012, 11:55 last edited by
        #3

        Sorry I seem to have made a mistake in posting here. It should be

        @GoodLib = function (param) {
        //Some action
        };@

        and GoodLib is the name of the global object that the library creates so that I can do calls like :

        @new GoodLib(someParam)@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          daliusd
          wrote on 28 Dec 2012, 12:18 last edited by
          #4

          OK. Your code looks good. What does not work for you? Do you get any error message?

          The only thing that you must be aware about: each import creates independent space (or at least that's my impression). It is better to use properties for keeping global state.

          1 Reply Last reply
          0

          3/4

          28 Dec 2012, 11:55

          • Login

          • Login or register to search.
          3 out of 4
          • First post
            3/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved