Solved Getting the index of the outer Repeater of nested Repeater
-
I have a repeater inside another repeater.
import QtQuick 2.6 import QtQuick.Window 2.2 Window { id: win visible: true width: 640 height: 480 Column { Repeater { model: 10 Row { Repeater { model: 2 Text { text: "I'm item " + index + " " MouseArea { anchors.fill: parent onClicked: console.log(index) } } } } } } }
The window looks something like this:
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1 <------
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1
I'm item 0 I'm item 1Let's say I clicked on the item by that arrow, currently I can get column's index. How can I find the row's index?
Thanks in advance
-
Hi!
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") Column { Repeater { model: 10 Row { property int rowIndex: index Repeater { model: 10 Rectangle { property int columnIndex: index width: 60 height: 30 color: "orange" border.width: 1 Text { anchors.centerIn: parent text: rowIndex + ", " + columnIndex } } } } } } }
Edit: oops, rows and columns were interchanged.
-
Thank you.