Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved Using "parent->findChild<QObject*>("objectName")"function,return null,when I find a ItemDelegate QML

    QML and Qt Quick
    2
    3
    885
    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.
    • D
      Daryl_X last edited by

      ListView {
                  id: listView
                  objectName: "mainListView"
                  currentIndex: -1
                  anchors.fill: parent
                  anchors.top: parent.Top
                  anchors.topMargin: 0.22*parent.height
      
                  delegate: ItemDelegate {
                      id: mainItemDelegate
                      objectName: "mainItemDelegate"
                      width: parent.width
                      anchors.horizontalCenter: parent.horizontalCenter
      
                      Image {
                          width: 0.1*parent.width
                          height: 0.8*parent.height
                          anchors.left: parent.left
                          anchors.leftMargin: 0.1*parent.width
                          source: model.icon
                      }
                      Label {
                          width: 0.5*parent.width
                          height: parent.height
                          text: model.title
                          anchors.horizontalCenter: parent.horizontalCenter
                      }
      
                      highlighted: ListView.isCurrentItem
                      onClicked: {
                          if (listView.currentIndex != index) {
                              listView.currentIndex = index
                              mainStackView.replace(model.source)
                              if(2==index)
                              {
                                  mainMenu.drawerItemChanged(index)
      //                            toolBarTop.visible = fasle
                              }
                          }
                          mainDrawer.close()
                      }
                  }
      

      This is my code in QML.

      Arvindhan Ponnusamy 1 Reply Last reply Reply Quote 0
      • Arvindhan Ponnusamy
        Arvindhan Ponnusamy @Daryl_X last edited by

        @Daryl_X Refer the link which explains your query.
        https://forum.qt.io/topic/7401/problem-with-finding-qml-elements-placed-within-listview-s-delegate-from-c-code-resolved/5

        D 1 Reply Last reply Reply Quote 0
        • D
          Daryl_X @Arvindhan Ponnusamy last edited by

          @Arvindhan-Ponnusamy I run the code run time,but still.

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