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. I have a question about rectangle, thanka!
Forum Updated to NodeBB v4.3 + New Features

I have a question about rectangle, thanka!

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

    in my program , when first run the program ,the rectangle read the listmodel's data.
    i want to click the button in the rectangle to reste the data that rectangle readed.
    how to make it?
    for example:
    Rectangle{
    Rectangle{
    x: get(0).listmodel.x
    y:get(0).listmodel.y
    }
    Button{
    // reset the x and y ,how to do it?
    }
    }

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

      Hi,

      Can you explain what do you mean by reset ? Do you want to default it to 0 ?
      Then just access the Rectangle using its id and set X and Y to 0.

      157

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hill
        wrote on last edited by
        #3

        i mean :in listmodel ,every element save a group x and y coordinate.

        when program first running,Rectangle :get(0).listmodel.x y:get(0).listmodel.y.
        then i press button , so Rectangle :get(1).listmodel.x y:get(1).listmodel.y.,acquire new x and y coordinate.

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

          Well then you can use the "contentItem":http://qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-flickable.html#contentItem-prop and get the childrens and then access its x and y.

          E.g

          @
          listview.contentItem.children[1].x
          listview.contentItem.children[1].y
          @

          This gives the item a index 1 in ListView.

          157

          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