Unsolved Need help please: TypeError: Cannot read property 'currentIndex' of undefined
-
so in my project, I am trying to: when a button is clicked , it must duplicate a layout so that I use repeater as figured below:
so as I mentionned above I obtain an error: Cannot read property 'currentIndex' of undefined, and this property is owned by 2 combobox that have an id cc1 and cc2
where is the problem please? -
Need help please is there any solution for that.
-
@ENSAO_CHEIKH Where are these two combo boxes with IDs cc1 and cc2?
Also, please post your code as text, not screen-shots. This way other people can more easily change and post it again. -
HI, @jsulm ,I am sorry for that, I m new here ,here is my code
import QtQuick 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls 1.2import LectureTrame 1.0
ApplicationWindow{
id:app
visible: true
title: qsTr("CAN'S FRAME")property int margin: 11 width: col.implicitWidth + 2 * margin height: col.implicitHeight + 2 * margin minimumWidth: col.Layout.minimumWidth + 2 * margin minimumHeight: col.Layout.minimumHeight + 2 * margin
ColumnLayout{
id:col
anchors.fill: parent
anchors.margins: marginLectureTrame{ id:trame } GroupBox{ id:g1 Layout.fillWidth: true Text { id: txt1 text: qsTr("Can Frame Lecture") anchors.centerIn: parent font.pixelSize: 15 color: "blue" font.bold: true font.italic: true } } GroupBox{ id:g2 Layout.fillWidth: true RowLayout{ id: rowLayout anchors.fill: parent Text{ id:test2 text: "Trame 0x :" // anchors.verticalCenter: parent.verticalCenter font.bold: true font.pixelSize: 12 font.italic: true } TextField{ id:t1 Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(0,t1.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength: 2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 1" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t2 Layout.fillWidth: true onTextChanged: trame.getText(1,t2.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 width: 20 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 2" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t3 Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(2,t3.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength: 2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 3" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t4 Layout.fillWidth: true onTextChanged: trame.getText(3,t4.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 4" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t5 text: " " Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(4,t5.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 5" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t6 text: " " Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(5,t6.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 6" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t7 Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(6,t7.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 7" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } TextField{ id:t8 Layout.fillWidth: true Layout.minimumWidth: 100 onTextChanged: trame.getText(7,t8.text) validator: RegExpValidator { regExp: /[0-9A-F]+/ } maximumLength:2 Text{ anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.top text: "OCTECT 8" font.pixelSize: 12 font.italic: true Layout.fillWidth: true color: "red" } } Button{ id:load text: "Charger" width: 150 height: 40 onClicked:repeater.model.hexx.text=trame.getHex(repeater.cc1.currentIndex,repeater.cc2.currentIndex) } }
}
GroupBox{ id:g3 implicitWidth: 250 implicitHeight: 80 Layout.fillWidth: true Layout.fillHeight: true ColumnLayout{ anchors.fill: parent //anchors.left: champ1.right // anchors.leftMargin: 100 //anchors.horizontalCenter: champ1.horizontalCenter // anchors.verticalCenter: champ1.verticalCenter Layout.fillHeight: true Layout.fillWidth: true id:cl // onClick: repeater.model.hexx.text=trame.getHex(repeater.model.cc1.currentIndex,repeater.model.cc2.currentIndex) Repeater { id:repeater model: 1
GridLayout{
id:gridproperty int ondex: 1 property int ro: 0 onOndexChanged: { button1.checked = ondex == 0 button2.checked = ondex == 1 } //anchors.fill: parent //anchors.left: champ1.right // anchors.leftMargin: 100 //anchors.horizontalCenter: champ1.horizontalCenter // anchors.verticalCenter: champ1.verticalCenter columns: 14 columnSpacing: 20 flow: GridLayout.LeftToRight y:50 Text { id:debut text: "Octet Début" //anchors.top: g3.top Layout.row: 0 Layout.column: 2
}
Text {
id:fin
text: "Octet Fin"Layout.row: 0 Layout.column: 3
}
Text {
id: hex
text: " Valeur en HEX "Layout.row:0 Layout.column: 4 } Text { text: " Facteur" Layout.row: 0 Layout.column: 7
}
Text {text: " Nom" Layout.row: 0 Layout.column: 8
}
Text {
id: decimal
text: " Coversion "
Layout.column: 10}
Label { id: champ1 text: "Champs 1 " font.pixelSize: 12 font.italic: true padding: 10 Layout.fillWidth: true Layout.fillHeight: true Layout.column: 0 Layout.row: 1
}
//RowLayout{ // anchors.left: champ1.right // anchors.leftMargin: 100 // anchors.horizontalCenter: champ1.horizontalCenter //anchors.verticalCenter: champ1.verticalCenter // Layout.fillHeight: true // Layout.fillWidth: true //spacing: 25 ComboBox{ id:cc1 model: ["1", "2", "3","4","5","6","7","8"] Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 2 } ComboBox{ id:cc2 model: ["1", "2", "3","4","5","6","7","8"] Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 3 } TextField{ id:hexx Layout.fillHeight: true Layout.fillWidth: true onTextChanged: {conversion.text=trame.convertHex(button1.checked,hexx.text)*trame.dec(text4.text) console.log(trame.convertHex(button1.checked,hexx.text)) console.log(button1.checked)} Layout.row: 1 Layout.column: 4 } RadioButton { id: button1 text: "Signé" onClicked:{ grid.ondex = 0 } Layout.row: 1 Layout.column: 5 } RadioButton { id: button2 text: "Non signé" onClicked:{ grid.ondex = 1 } Layout.row: 1 Layout.column: 6 } TextField{ id:text4 Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 7 onTextChanged: conversion.text=trame.convertHex(button1.checked,hexx.text)*trame.dec(text4.text) } TextField{ Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 8 } Text { id: texhex text: qsTr("0x") Layout.row: 1 Layout.column: 9 } TextField{ id:conversion Layout.fillHeight: true Layout.fillWidth: true Layout.row: 1 Layout.column: 10 } Button{ text: "+" Layout.fillHeight: true Layout.fillWidth: true onClicked: repeater.model += 1 } Button{ text: "-" Layout.fillHeight: true Layout.fillWidth: true onClicked: repeater.model -= 1 } //} }
}
}}
}
}and the combobox are in line 537,