Hello all...

I'm writing some JavaScript code inside QML.  What I'd like to do is be able to 
access an object via id where the id is in a JavaScript string.

For example, given the QML:

        CheckBox {
            id: english_weight1
            text: qsTr("2.5 lb")
        }

and the JavaScript fragment:

        var idName = "english_weight1";
        if (idName.checked)
            // do something is the box is checked...

But I want the idName in the "if" statement to refer to the value of the 
JavaScript variable "idName", in other words,
"english_weight1.checked". I believe I could use eval:

        if (eval(idname + ".checked")) ...

but everything I've read says eval is to be avoided.

If it helps or makes any difference, the CheckBox is in a Column with id 
myColumn.  I was thinking something like
myColumn[idName] would do the trick, but I'm only guessing.

I hope this is a clear enough description... please let me know if any more 
details are needed.

Any thoughts?

Thanks!

-Eric
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to