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. [SOLVED]Strange JS behavior
QtWS25 Last Chance

[SOLVED]Strange JS behavior

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.9k Views
  • 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.
  • I Offline
    I Offline
    ixSci
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pvarga
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ixSci
        wrote on last edited by
        #3

        Hi pvarga, xMarks has QList<float> type and it is provided by the C++ side

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ixSci
          wrote on last edited by
          #4

          So, bug not in the JS but in my code instead. xMarks is not QList<float> but QList<QString>.

          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