Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]access the property of elements of all components created ever in one ducument

[SOLVED]access the property of elements of all components created ever in one ducument

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 1.6k 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
    mehrdad
    wrote on last edited by
    #1

    an important question for me
    i have a document and i want create some QML elements in that by this code
    @
    var component5 = Qt.createComponent("Shape_circle.qml");
    if (component5.status == Component.Ready) {
    var circle = component5.createObject(adder);
    circle.x=mouseX
    circle.y=mouseY
    component5.destroy();
    }
    @
    that is called using createComponent metod for having same elements in a doc...
    now! what i want is that how can i have this elements in a list
    for example, i create 10 shapes and i want to change second shape color or size...
    or i want to save this shapes size and colors in a file...
    can U help me?
    thanks

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      if I understood you correctly, you can store the objects in an array
      @
      property var arrayOfObjects : []
      var circle = component5.createObject(adder);
      arrayOfObjects[0] = circle
      @

      157

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

        thanks...but it contains an error: Expected token `,'
        and red underline under var in line1

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          OfCourse, if you use as it is. property var arrayOfObjects is meant to be global.

          157

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mehrdad
            wrote on last edited by
            #5

            thank u veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy much!!!!!
            it work!

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mehrdad
              wrote on last edited by
              #6

              an other question...
              can i access childrens of an element
              for example in circle.qml file i have a button that i want change its color in especial created element...

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

                Yes. From QML you can use the children property. For eg
                @
                circle.children[0].color = "red" //just find the exact element
                @

                157

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mehrdad
                  wrote on last edited by
                  #8

                  thanks again!!!!!!!
                  it work too!!!

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mehrdad
                    wrote on last edited by
                    #9

                    thanks again!!!!!!!
                    it work too!!!

                    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