[SOLVED]Strange JS behavior
-
wrote on 26 Mar 2011, 12:02 last edited by
Hi there!
I've just stumbled on some strange JavaScript behavior which I don't understand totally.
I have the following code for one of the QML item property:
@xMax: {
var maximum = 0;for(var i = 0; i < xMarks.length; i++){ var data = xMarks[i]; console.log("data: " + data + ", maximum:" + maximum + ", result: " + (data > maximum)) if(data > maximum){ maximum = data; } } return maximum; }@
And it prints: !http://ybex.com/t/in8iai32h6khg3r2u72ph5x5kbb4homykr9ue41s.png(that)!
It works as such with all values more then 6. It works as it should with all values less then 6. Is it a bug? It seems very strange to me -
wrote on 26 Mar 2011, 16:31 last edited by
Hi ixSci,
I have tried your example and it works for me.
What is the type of the xMarks array? I created an own one for the test:
@
var xMarks = new Array(6.0, 12.0, 18.0, 30.0);
@
With this array the console.log prints it in integer format instead of double (e.g. "6" instead of "6.00").
Could you share more information about the using of xMax property? I just started to get acquainted with QML. -
wrote on 27 Mar 2011, 06:38 last edited by
Hi pvarga, xMarks has QList<float> type and it is provided by the C++ side
-
wrote on 27 Mar 2011, 07:34 last edited by
So, bug not in the JS but in my code instead. xMarks is not QList<float> but QList<QString>.
2/4