<?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[function binding property]]></title><description><![CDATA[<p dir="auto">hello together<br />
following I have:</p>
<pre><code>function buttonIsSelected(index)
{
	if(index &gt;= 0){
		listViewId.currentIndex = index
		console.log("listViewId Index --------------------------------------------------",index)
		return true
	}else
		return false
}

ListView
{
	id: listViewId
	anchors.top = parent.top
	.....
	model: 4
	delegate: Button {
		id: tabButtonId
		width: 150
		height: 150
		selected: buttonIsSelected(index)   // Problem is hier
		.....
	}

}

</code></pre>
<p dir="auto">Why does the function buttonIsSelected (index) always return false?<br />
What am I doing wrong?</p>
<p dir="auto">thanks</p>
]]></description><link>https://forum.qt.io/topic/108628/function-binding-property</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 17:02:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/108628.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Nov 2019 07:14:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 11:50:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/galilio">@<bdi>Galilio</bdi></a><br />
fixed the link, should now work</p>
]]></description><link>https://forum.qt.io/post/560704</link><guid isPermaLink="true">https://forum.qt.io/post/560704</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 08 Nov 2019 11:50:16 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 11:43:38 GMT]]></title><description><![CDATA[<p dir="auto">Link leider geht nicht</p>
]]></description><link>https://forum.qt.io/post/560702</link><guid isPermaLink="true">https://forum.qt.io/post/560702</guid><dc:creator><![CDATA[Galilio]]></dc:creator><pubDate>Fri, 08 Nov 2019 11:43:38 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 11:49:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/galilio">@<bdi>Galilio</bdi></a><br />
genau<br />
<a href="https://vimeo.com/371847377" target="_blank" rel="noopener noreferrer nofollow ugc">https://vimeo.com/371847377</a></p>
]]></description><link>https://forum.qt.io/post/560684</link><guid isPermaLink="true">https://forum.qt.io/post/560684</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 08 Nov 2019 11:49:55 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 10:46:41 GMT]]></title><description><![CDATA[<p dir="auto">Die Farbe der selectiereten Button bleibt aber gleich und das ist nicht das Ziel.<br />
Ziel wäre: sobald ich einen button selktiere muss der andere Button nicht mehr die selktiere frabe haben<br />
sprich:<br />
Button 1 ist selktiert (color "green")<br />
Button 2 ist selktiert (color "green") und Button 1 wird "red" gefährbt<br />
...</p>
]]></description><link>https://forum.qt.io/post/560683</link><guid isPermaLink="true">https://forum.qt.io/post/560683</guid><dc:creator><![CDATA[Galilio]]></dc:creator><pubDate>Fri, 08 Nov 2019 10:46:41 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 10:23:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/galilio">@<bdi>Galilio</bdi></a><br />
I'm not sure I understand your problem, this</p>
<pre><code>ListView
    {
        id: listViewId
        anchors.fill: parent
        model: 4
        delegate: Button {
            id: tabButtonId
            width: 150
            height: 150
            property bool selected:listViewId.currentIndex === index/* buttonIsSelected(index)*/   // Problem is hier
            onSelectedChanged: console.log("selected changed to", selected, "of index:", index)
            text: index
            background: Rectangle{
                color: tabButtonId.selected ? "green" : "red"
            }
            onClicked:{
                listViewId.currentIndex = index
            }
        }
    }
</code></pre>
<p dir="auto">works just fine!</p>
]]></description><link>https://forum.qt.io/post/560680</link><guid isPermaLink="true">https://forum.qt.io/post/560680</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 08 Nov 2019 10:23:53 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 10:21:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/galilio">@<bdi>Galilio</bdi></a></p>
<p dir="auto">The problem with this notation (property bool selected: listViewId.currentIndex === index)  is that index and currentIndex do not always have the same value</p>
]]></description><link>https://forum.qt.io/post/560679</link><guid isPermaLink="true">https://forum.qt.io/post/560679</guid><dc:creator><![CDATA[Galilio]]></dc:creator><pubDate>Fri, 08 Nov 2019 10:21:08 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 10:14:58 GMT]]></title><description><![CDATA[<p dir="auto">What is wrong if I do so in ListView?</p>
<pre><code>property bool selected: listViewId.currentIndex === index
</code></pre>
]]></description><link>https://forum.qt.io/post/560676</link><guid isPermaLink="true">https://forum.qt.io/post/560676</guid><dc:creator><![CDATA[Galilio]]></dc:creator><pubDate>Fri, 08 Nov 2019 10:14:58 GMT</pubDate></item><item><title><![CDATA[Reply to function binding property on Fri, 08 Nov 2019 07:29:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/galilio">@<bdi>Galilio</bdi></a> no idea, works absolutely fine for me</p>
<pre><code>Window {
    visible: true
    width: 400
    height: 750
    title: qsTr("Hello World")

    function buttonIsSelected(index)
    {
        if(index &gt;= 0){
            listViewId.currentIndex = index
            console.log("listViewId Index --------------------------------------------------",index)
            return true
        }else
            return false
    }

    ListView
    {
        id: listViewId
        anchors.fill: parent
        model: 4
        delegate: Button {
            id: tabButtonId
            width: 150
            height: 150
            property bool selected: buttonIsSelected(index)   // Problem is hier
            onSelectedChanged: console.log("selected changed to", selected)
        }
    }
}
</code></pre>
<pre><code>//Output
qml: listViewId Index -------------------------------------------------- 0
qml: selected changed to true
qml: listViewId Index -------------------------------------------------- 1
qml: selected changed to true
qml: listViewId Index -------------------------------------------------- 2
qml: selected changed to true
qml: listViewId Index -------------------------------------------------- 3
qml: selected changed to true
</code></pre>
]]></description><link>https://forum.qt.io/post/560640</link><guid isPermaLink="true">https://forum.qt.io/post/560640</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 08 Nov 2019 07:29:16 GMT</pubDate></item></channel></rss>