Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to change element in array - Qt creator
Forum Updated to NodeBB v4.3 + New Features

How to change element in array - Qt creator

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 2.1k 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.
  • M Offline
    M Offline
    Megaplayer
    wrote on last edited by
    #1

    Hi !
    I want know how to change and delete one element in array. I'm using following code but nothing changes. I'm using Qt creator from Qt SDK 1.2.1. I'm tried it too with some javascript functions but Qt creator don't recognize functions.

    @Item {
    property variant sortedArray: ['1','2','3','4','5','6','7','8']
    }

    item1.sortedArray[4] = "2"@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      QML is declarative, not imperative. You need to add the code from line 5 somewhere where it will actually be invoked (like Component.onCompleted slot, or MouseArea mouse click, etc.).

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Megaplayer
        wrote on last edited by
        #3

        I know about it, it was just part of my code. Here is my entire code.

        @import QtQuick 1.1
        import com.nokia.symbian 1.1

        Page {
        id: mainPage

        Item {
          id: item1
          property variant sortedArray: ['1','2','3','4','5','6','7','8']
          property int a: 0
        }
        
        Button {
            id: button1
            x: 136
            y: 121
            text: "Button"
            onClicked:
            {
                item1.sortedArray[6] = "2"
                while (item1.a < 8)
                {
                    textfield1.text = (textfield1.text + " " + item1.sortedArray[item1.a])
                item1.a++;
        

        }
        }
        }

        TextField {
            id: textfield1
            x: 90
            y: 240
            width: 180
            height: 50
            text: ""
        }
        

        }
        @

        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