Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Binding a TextInput value to a ListView currentItem - ReferenceError: Can't find variable

    QML and Qt Quick
    1
    1
    2074
    Loading More Posts
    • 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.
    • A
      AllenB2012 last edited by

      I have a ListView (id: ios_Elements) that I am trying to access from javascript but I can't seem to expose it correctly.
      The ListView is nested in another ListView (ios_Pages). I am using two xml models located below.

      Please help me expose the ios_Elements to my function.

      Thank you.
      Allen

      @
      import QtQuick 1.1

      Item {
      id: maincontainer
      height: 720
      width: 1024
      property int menuItemMaxVal: 0
      property int menuItemReference: 0

      function NextOnClick(destinationpageid) {
      var pageshow = 0;
      pageshow = destinationpageid;
      ios_Pages.positionViewAtIndex (pageshow, ListView.Beginning);
      }

      function NextOnInput(menuItemReference) {
      var pageshow = 0;
      ios_Elements.currentIndex = menuItemReference; //- ios_Elements ReferenceError: Can't find variable
      pageshow = ios_Elements.currentItem.ios_elementsModel.destinationpageid;
      ios_Pages.positionViewAtIndex (pageshow, ListView.Beginning);
      }

      Item {
      id: contentcontainer
      height: 410
      anchors.top: parent.top
      anchors.left: parent.left
      anchors.right: parent.right
      anchors.margins: 12
      anchors.topMargin: 6

       Component {
           id: ios_pageDelegate
      
           Item {
                  id:flickablenextmenu
                  width: contentcontainer.width
                  height: contentcontainer.height
      
                  Rectangle {
                      id: flickcontainer
                      color: "transparent"
                      width: parent.width
                      height: parent.height
                      anchors: parent
                      radius: 5
                      border.color: "black"
                      border.width: 1
      
                      Text {
                          id: elementPageTitle
                          anchors.centerIn: contentcontainer.Center
                          anchors.horizontalCenter: parent.horizontalCenter
                          font.pointSize: 12
                          font.bold: true
                          text: pagetitle
                     }
      
                         Component {
                               id: ios_elementDelegate
      
                               Item  {
                                   id: listitemselement
                                   width: ios_Elements.width
                                   property int parentpage: parentpageid
                                   property int curpageid: pageid
                                   property string contenttype: type
                                   property int indexValue: parseInt(index)
                                   property int destinationpage: destinationpageid
      
                                   Component.onCompleted: listmatches()      
      
                                   function listmatches()  {
                                      var counter = 0;
                                      if (parentpage === curpageid)
                                      {
                                           var component = Qt.createComponent("Ios_element.qml");
                                           if (component.status === Component.Ready)
                                           {
                                             var item = component.createObject( listitemselement );
                                           }
                                           counter++;
                                           listitemselement.height = (ios_Elements.count - counter) - 22;
                                       }
                                   }
                               }
                           }
      
                   ListView {
                       id: ios_Elements
                       anchors.topMargin: 12
                       anchors.fill: parent
                       orientation: ListView.Vertical
                       model: Ios_ElementsModel {}
                       delegate: ios_elementDelegate
                       interactive: false
                   }
                  }
                }
              }
      
       ListView {
           id: ios_Pages
           flickableDirection: Flickable.HorizontalFlick
           model: Ios_PageModel {}
           delegate: ios_pageDelegate
           anchors.fill: parent
           orientation: ListView.Horizontal
           snapMode: ListView.SnapOneItem
       }
      

      }

       Rectangle {
           id: bottompanel
           color: "transparent"
           height: 75
           anchors.top: contentcontainer.bottom
           anchors.left: maincontainer.left
           anchors.right: maincontainer.right
           anchors.bottom: maincontainer.bottom
           anchors.margins: 12
           anchors.topMargin: 6
           radius: 5
           border.color: "black"
           border.width: 1
      
           MenuSelectInput {
               id: menuselectInput
               anchors.topMargin: 2
               height: 25
               width: 215
          }
       }
      

      }

      XmlListModel {
      id: ios_elementsModel
      source: "/IOS_ControlPanel/menuitems.xml"
      query: "/MenuItems/MenuItem"

      XmlRole { name: "id"; query: "id/number()" }
      XmlRole { name: "type"; query: "type/string()" }
      XmlRole { name: "index"; query: "index/string()" }
      XmlRole { name: "verbage"; query: "verbage/string()" }
      XmlRole { name: "parentpageid"; query: "Parentpageid/number()" }
      XmlRole { name: "destinationpageid"; query: "destinationpageid/number()" }
      

      }

      XmlListModel {
      id: xmlPagemodel
      source: "/IOS_ControlPanel/pages.xml"
      query: "/Pages/Page"

      XmlRole { name: "pageid"; query: "pageid/number()" }
      XmlRole { name: "pagetitle"; query: "pagetitle/string()" }
      

      }
      @

      1 Reply Last reply Reply Quote 0
      • First post
        Last post