Documentation / programmers manual for scripting

Hi,
I was trying to check if a Number variable “Number 2” is changed and if “Number 1” == “Number 2” == 1 then press and release a button (or do any task).

Is there a documentation on various signals, property , usage / code examples that can be used for reference? Also if there was code completion inside the editor that can help too

import QtQuick 2.5
Item {
    Connections {
        target: document.childByName("Number 2").scriptAdaptor
        onEventItemChanged: {
        if(document.childByName("Number 1").number == document.childByName("Number 2").number) 
            console.log("yes!!!")
        }
    }
}

You need to use Number changed event:

image

You can convert actions to code:

image

Complete code will be:

import QtQuick 2.15

Item {
    Connections {
        target: document.childByName("Number 2").content.scriptAdaptor
        onEventNumberChanged: {
            if (document.childByName("Number 2").content.doubleNumber == "1" && document.childByName("Number 2").content.doubleNumber == document.childByName("Number 1").content.doubleNumber)
                console.log("Yes")
            else
                console.log("No")
        }
    }
}

Example project numbers.pma (6.4 KB)

1 Like

thank you .
Wasnt aware of generating script. Really helpful


Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.