How do I skip the indices in a repeater such that I can create the following exact string: A • D • G • J • M • P • S • V • Z
Is this achievable?
My new code based on suggested answers, I created a function newLetters(index)
to determine which letters to print and now my output gives the following string: A •• D •• G •• J •• M •• P •• S •• V •• Z
?
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
id: root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
property string letters: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Rectangle {
id: control
anchors.fill: parent
function newLetters(index) {
if(letters[index] === "A")
return true
if(letters[index] === "D")
return true
if(letters[index] === "G")
return true
if(letters[index] === "J")
return true
if(letters[index] === "M")
return true
if(letters[index] === "P")
return true
if(letters[index] === "S")
return true
if(letters[index] === "V")
return true
if(letters[index] === "Z")
return true
}
Repeater {
anchors.fill: parent
model: 26
Text {
text: control.newLetters(index) ? root.letters[index] : " • "
}
}
}
}