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. How to change a property of an object in an array list
Forum Updated to NodeBB v4.3 + New Features

How to change a property of an object in an array list

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.5k 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.
  • K Offline
    K Offline
    Kelteseth
    wrote on last edited by
    #1

    Hi Qt Hackers
    in this example ( http://harmattan-dev.nokia.com/docs/library/html/qt4/declarative-tutorials-samegame-samegame2.html ) an array is used to store the objects of the gamefield. When they restart the game all the objects going to be deleted. My question is: Is there a way to change the properties of an single oject in this array? I've tried this:
    @board[0].visible = false@

    But all I get is a type error: Cannot set property "visible" of undefined

    Thanks
    Eli

    1 Reply Last reply
    0
    • D Offline
      D Offline
      daliusd
      wrote on last edited by
      #2

      Maybe that will give you some hints. This is output from node.js but javascript is javascript. Actually download node.js and try to play around with it a little bit:

      @> a = new Array(10)
      [ , , , , , , , , , ]

      a[0]
      undefined
      a[0].visible
      TypeError: Cannot read property 'visible' of undefined
      at repl:1:6
      at REPLServer.eval (repl.js:80:21)
      at Interface.<anonymous> (repl.js:182:12)
      at Interface.emit (events.js:67:17)
      at Interface._onLine (readline.js:162:10)
      at Interface._line (readline.js:426:8)
      at Interface._ttyWrite (readline.js:603:14)
      at ReadStream.<anonymous> (readline.js:82:12)
      at ReadStream.emit (events.js:88:20)
      at ReadStream._emitKey (tty.js:327:10)
      a[0] = {visible: 'hi'}
      { visible: 'hi' }
      a[0].visible
      'hi'
      a[0].visible = 'bye'
      'bye'
      a[0].visible
      'bye'
      @

      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