Javascript error: cant find variable:(

  • I have a qml file and I am checking for some condition in js file. I imported the js file as Coco in my qml file, and while cheking the condition I gave Coco.function();. an error in the js file "cant find reference variable". The variable is still available in my qml file. I am sure that this is a silly error but am breaking my head off with this. ANy help is appreciated.

  • please post some code

  • JS file

    @function val()



    function func() {

    if(param_value.text < "70"*1)



    in qml file


    TextEdit {
    id: param_value
    width: 70
    height: 15
    onTextChanged: Coco.func();

                        font.pixelSize: 12

    onClicked: {param_value.text=slider.slidervalue;
    error i get is: reference error: cant find variable param_value

  • Better than having your id in the javascript, you can pass the id as a parameter

  • sorry dmcr, I did not understand. cud u just quote an example. Thanks

  • i don't know exactly where is your problem since you don't gave the full code with header, etc...

    What i was suggesting is just a better manner :
    instead of func() {.....
    create a function func_(componentId){....
    where you can then update values componentId.text = ....

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.