<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[List Item highlight under StackView]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I want to highlight an Item of a List View which is under StackView pages. The use case i am trying to achieve is<br />
On mainPage of StackView there is an ListView and among the List Items if user an Item then it should navigate to next page and same item should get highlighted from the List View that is present in the nextPage and action of the particular item should be visible in rectangle present beside the ListView in the next page with the value that is received via stackView PUSH.</p>
<p dir="auto">Here is the Sample application below that i am trying to achieve the same</p>
<p dir="auto">main.qml</p>
<pre><code>import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    StackView{
        id: mainView

        anchors.fill: parent
        initialItem: mainPage

        Page{
            id: mainPage

            ListView {
                width: 400
                height: 600

                model: ListModel{
                    ListElement {
                        name: "Hai"
                    }

                    ListElement {
                        name: "Hai1"
                    }

                    ListElement {
                        name: "Hai2"
                    }

                    ListElement {
                        name: "Hai3"
                    }

                    ListElement {
                        name: "Hai4"
                    }

                    ListElement {
                        name: "Hai5"
                    }
                }

                delegate: Button {
                    text: model.name
                    onClicked: {
                        mainView.push("MePage.qml",{selectedIndex:index})
                    }
                }
            }
        }
    }
}
</code></pre>
<p dir="auto">MePage.qml</p>
<pre><code>import QtQuick 2.0

import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2

Page {
    id: root
    //anchors.fill: parent

    property int selectedIndex: -1
    onSelectedIndexChanged: {
        console.error("===============&gt;IndexChanged", selectedIndex)
    }

    RowLayout{
        anchors.fill: parent
        ColumnLayout {
            RowLayout {
                Layout.alignment: Qt.AlignTop
                Button {
                    id: a

                    text: "A"
                    onClicked: {
                        console.error("A")
                    }
                }

                Button {
                    id: b

                    text: "B"
                    onClicked: {
                        console.error("B")
                    }
                }
            }

            Rectangle {
                Layout.fillWidth: true
                color: "black"
                height: 2
            }

            ListView {
                id: msModel

                currentIndex: selectedIndex
                width: 180; height: 400
                model: ListModel {
                    ListElement {
                        name: "Hia"
                    }

                    ListElement {
                        name: "Hia1"
                    }

                    ListElement {
                        name: "Hia2"
                    }

                    ListElement {
                        name: "Hia3"
                    }

                    ListElement {
                        name: "Hia4"
                    }

                    ListElement {
                        name: "Hia5"
                    }

                    ListElement {
                        name: "Hia6"
                    }

                    ListElement {
                        name: "Hia6"
                    }

                    ListElement {
                        name: "Hia7"
                    }

                    ListElement {
                        name: "Hia8"
                    }

                    ListElement {
                        name: "Hia9"
                    }

                    ListElement {
                        name: "Hia10"
                    }

                    ListElement {
                        name: "Hia11"
                    }
                }

                delegate: Button {
                    height: 50
                    text: model.name
                    onClicked: {
                        root.selectedIndex = index
                    }
                }

                highlight: Rectangle{
                    width: parent.width
                    visible: (selectedIndex === msModel.currentIndex)
                    color: "blue"
                }
            }
        }
        Rectangle {
            id: divider

            width: 2
            color: "black"
            Layout.fillHeight: true
        }

        Rectangle{
            id: contentRect

            width: msModel.width
            height: msModel.height
            color: "lightblue"
            Text{
                text: "Item--" + root.selectedIndex
            }
        }
    }
}
</code></pre>
<p dir="auto">The expectation is If User selects the List Item "Hai" from the ListView in main.qml then the same element should be in highlighted state when StackView navigates the User to MePage.qml and Item1 should be visible on the leftside rectangle of MePage<br />
Any help on the same is highly appreciated!!<br />
Thanks in advance !!</p>
<p dir="auto">Regard's,<br />
Rohith.G</p>
]]></description><link>https://forum.qt.io/topic/156276/list-item-highlight-under-stackview</link><generator>RSS for Node</generator><lastBuildDate>Sun, 10 May 2026 01:03:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/156276.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Apr 2024 09:33:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to List Item highlight under StackView on Fri, 26 Apr 2024 04:28:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dheerendra">@<bdi>dheerendra</bdi></a></p>
<p dir="auto">Yes, the ListView in the both the pages will use the same model.</p>
]]></description><link>https://forum.qt.io/post/798072</link><guid isPermaLink="true">https://forum.qt.io/post/798072</guid><dc:creator><![CDATA[AROH]]></dc:creator><pubDate>Fri, 26 Apr 2024 04:28:48 GMT</pubDate></item><item><title><![CDATA[Reply to List Item highlight under StackView on Thu, 25 Apr 2024 12:16:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aroh">@<bdi>AROH</bdi></a></p>
<p dir="auto">Is Index for Hai is same for the first Page &amp; second page ?</p>
]]></description><link>https://forum.qt.io/post/797994</link><guid isPermaLink="true">https://forum.qt.io/post/797994</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Thu, 25 Apr 2024 12:16:35 GMT</pubDate></item><item><title><![CDATA[Reply to List Item highlight under StackView on Thu, 25 Apr 2024 11:11:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dheerendra">@<bdi>dheerendra</bdi></a></p>
<p dir="auto">For example:<br />
Suppose a user selects the “Hai2” list item on the first page. In the second page, the same “Hai2” item should appear in a highlighted state, indicated by a blue color. Although the index is correctly updated with the value selected by the user on the first page, the visual highlighting of the item is not working as expected.</p>
]]></description><link>https://forum.qt.io/post/797982</link><guid isPermaLink="true">https://forum.qt.io/post/797982</guid><dc:creator><![CDATA[AROH]]></dc:creator><pubDate>Thu, 25 Apr 2024 11:11:39 GMT</pubDate></item><item><title><![CDATA[Reply to List Item highlight under StackView on Thu, 25 Apr 2024 06:59:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/aroh">@<bdi>AROH</bdi></a></p>
<p dir="auto">What is the current issue ? If you can help with current issue faced by you, we may help. Few things added confusion for me at least.</p>
<p dir="auto">Also model size in main page &amp; MePage.qml are not matching.  After going to second page, what would you liked to do ? MainPage will dis appear once go to next page. There is no action exist to come back.</p>
]]></description><link>https://forum.qt.io/post/797922</link><guid isPermaLink="true">https://forum.qt.io/post/797922</guid><dc:creator><![CDATA[dheerendra]]></dc:creator><pubDate>Thu, 25 Apr 2024 06:59:25 GMT</pubDate></item></channel></rss>