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. Need help please: TypeError: Cannot read property 'currentIndex' of undefined
Forum Updated to NodeBB v4.3 + New Features

Need help please: TypeError: Cannot read property 'currentIndex' of undefined

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 838 Views
  • 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.
  • E Offline
    E Offline
    ENSAO_CHEIKH
    wrote on last edited by ENSAO_CHEIKH
    #1

    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:
    bouton.PNG repeater.PNG

    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?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ENSAO_CHEIKH
      wrote on last edited by
      #2

      Need help please is there any solution for that.

      jsulmJ 1 Reply Last reply
      0
      • E ENSAO_CHEIKH

        Need help please is there any solution for that.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • E Offline
          E Offline
          ENSAO_CHEIKH
          wrote on last edited by
          #4

          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.2

          import 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: margin

          LectureTrame{
              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:grid

             property 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,

          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