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()
Forum Updated to NodeBB v4.3 + New Features

QML Javascript splice()

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 3.3k Views 1 Watching
  • 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 12 Jul 2017, 21:31 last edited by arozon 7 Dec 2017, 21:32
    #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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Jul 2017, 22:40 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 12 Jul 2017, 23:01
      1
      • S SGaist
        12 Jul 2017, 22:40

        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 12 Jul 2017, 23:01 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 12 Jul 2017, 23:15
        0
        • A arozon
          12 Jul 2017, 23:01

          @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 12 Jul 2017, 23:15 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

          1/4

          12 Jul 2017, 21:31

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved