Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Regular Contributor tkastlunger's Avatar
    Join Date
    Jun 2012
    Posts
    77
    I have a javascript file (myfile.js) which declares :

    var testVar = 0;

    then I have a file main.qml:

    import "myfile.js" as myfileJs;

    page{
    id :...;
    main2{
    id:testmain2;
    }
    button{
    onClicked:{
    myfileJs.testVar = 10;
    console.debug(myfileJs.testVar); ///Gives 10 on console
    pagestack.push(testmain2);
    }
    }
    }

    and another file, "main2.qml":

    import "myfile.js" as myfileJs;

    page{
    id :...2;
    button{
    onClicked:{
    console.debug(myfileJs.testVar); ///Gives 0 on console
    }
    }
    }

    Needless to say that in qmldir I declare main2 qml file.
    Anyone experienced the same?

  2. #2
    Regular Contributor vladestCh's Avatar
    Join Date
    Mar 2012
    Posts
    144
    try to add
    .pragma library
    to your js file at the beginning

Similar Threads

  1. Global variable in js file to use in more QML files
    By AlterX in forum [Archived] Qt Quick
    Replies: 0
    Last Post: 2011-07-24, 10:48
  2. Is global variable really bad in S60 3rd or above
    By is03zong in forum Symbian C++
    Replies: 5
    Last Post: 2010-10-12, 03:42
  3. how to decalre a global Variable
    By ragu. in forum Symbian C++
    Replies: 3
    Last Post: 2010-08-05, 07:54
  4. console exe global variable?
    By ptclin_2007 in forum Symbian C++
    Replies: 3
    Last Post: 2009-09-28, 04:18
  5. Use global variable in s3rd
    By andrew_lin in forum Symbian C++
    Replies: 6
    Last Post: 2008-05-03, 11:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved