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. Codes problem. Qml and Javascript
Forum Updated to NodeBB v4.3 + New Features

Codes problem. Qml and Javascript

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

    hi everyone im having a problem here you see my game.qml has this property
    @ id:scene
    width:360;height:640

    property int score: 0
    property int highScore:0
    property bool ready: false
    property bool paused: true
    property int level:0
    property int answered: 0
    
    signal clicked();
    signal levelLoaded();@
    

    it has a property level which is equal to 0

    and on my js file... i have this code

    @var answer;
    var question;

    //script for query
    var r = scene.level
    if(r == 0){
    first= Math.floor(Math.random()*19+1);
    second= Math.floor(Math.random()*19+1);
    answer=first+second;
    question=first+"+"+second;

    }@

    i want to use the property of my game.qml as a basis for the conditions on the if-else statements

    but everytime i do this. it always return this error/bug "scene[null] is not an object";

    anyone knows this?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      We lack some info here. How did you include the JS file? Is the JS a library? Is the code you provided inside a function?

      (Z(:^

      1 Reply Last reply
      0
      • E Offline
        E Offline
        externc
        wrote on last edited by
        #3

        I am guessing he has the javascript in a separate file and he isn't including it. OP, its probably easier to just stick that javascript code into the same QML file that scene is in.

        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