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. QML Javascript splice()
QtWS25 Last Chance

QML Javascript splice()

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 3.2k 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.
  • A Offline
    A Offline
    arozon
    wrote on last edited by arozon
    #1

    High, i am trying to splice an array i have that i use to store data. The array is pulled from a custom fileIO that returns a JSON object with the array inside... That in itself isn't a problem however splicing just doesnt work in QT 5.9 or am i doing it wrong..

    function spliceTest() {
       var ar = ["t","t"]; 
       console.log(ar.length); // return 2 which is what it should be..
       ar.splice(1,1);
       // Array length should now be 1...
       console.log(ar) // returns "t", "t"  What happened??
       console.log(ar.length) // still returns 2...
    }
    

    Any help would be greatly appreciated :D

    Sinc., Alex

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which exact version of Qt 5.9 are you using ?

      Can you provide a minimal compilable project that shows that behaviour ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        Which exact version of Qt 5.9 are you using ?

        Can you provide a minimal compilable project that shows that behaviour ?

        A Offline
        A Offline
        arozon
        wrote on last edited by
        #3

        @SGaist Actually running the code on a different project gave me the correct results i guess it has something to do with my main project. I will attempt to see whats different between the two projects and why one is not running the splice command.

        A 1 Reply Last reply
        0
        • A arozon

          @SGaist Actually running the code on a different project gave me the correct results i guess it has something to do with my main project. I will attempt to see whats different between the two projects and why one is not running the splice command.

          A Offline
          A Offline
          arozon
          wrote on last edited by
          #4

          The solution was quite simple, ar, from my test project already had an alias property in that name, its a dumb mistake but the alias overides the var object and qt gets mixed up, changing the name of the temporary var fixed everything

          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