Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:45:28+00:00 2026-06-14T22:45:28+00:00

I have listview with a nested listview in it in qml, how can i

  • 0

I have listview with a nested listview in it in qml, how can i get index of parent listview index in nested listview delegate?

Code sample:

ListView {
        id: listView
        anchors.fill: parent
        delegate: delegate
        model: myModel
    }

    Component {
        id: delegate
        Item {
            id: recipe
            width: listView.width
            height: 120


            Column {

                   // some text fields
                    ListView {
                        id: listView1
                        width: listView.width
                        height: 50
                        delegate: nextLevelDelegate
                        model: nextLevelList
                    }

                }
        }
    }

    Component {
        id: nextLevelDelegate
        Item{
                                        width: listView1.width
                                        height: 20
                                        Rectangle {
                                            id: background2
                                            x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
                                            color: "lightgray"
                                            border.color: "gray"
                                            radius: 5
                                        }
                                        Text {
                                            anchors.fill: parent
                                            id:nextLevelButton
                                            horizontalAlignment:Text.AlignHCenter
                                            text: modelData
                                        }
                                        MouseArea
                                        {
                                          anchors.fill: parent
                                          id: mouseArea
                                          onClicked: {
                                             window.buttonPressed(nextLevelButton.text,listView.currentIndex);//I need parent index here for calling c++ method with it
                                          }
                                        }
                                    }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:45:30+00:00Added an answer on June 14, 2026 at 10:45 pm

    Assign the index of the parent list view to a different property so it won’t be shadowed.

    ListView {
       id: listView1
       property int parentIndex: index
       width: listView.width
       height: 50
       delegate: nextLevelDelegate
       model: nextLevelList
    

    }

    parentIndex will be available within nextLevelDelegate as listView1.parentIndex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nested listview which I databind on the parent 'ItemDataBound' event, but
I have ListView which shows images from an ImageList. Now wanted to get index
i have a nested listview, i can bind the selected item of the basic
I am taking some code that I have used for a nested listview before
I have a ListView with Horizontal WrapPanel as its ItemsPanelTemplate. I want to get
I have a nested GridView that is placed inside a ListView. The GridView renders
I have a listview, where I set the datasource in the code-behind - this
I have a nested ListView control and within the ItemTemplate I need to make
If I have a nested ListView, and I'm calling a related table in LinQ,
I have the following nested listview... <asp:ListView ID=lvwRiskQuestions runat=server ItemPlaceholderID=QuestionItemPlaceholder> <LayoutTemplate> <asp:PlaceHolder ID=QuestionItemPlaceholder runat=server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.