<?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[Problems setting ComboBox currentIndex]]></title><description><![CDATA[<p dir="auto">QuickControls 2 using Qt 5.11....</p>
<p dir="auto">I've got a comboBox, and I'm trying to change the model and current index for it using javascript on a property change:</p>
<pre><code>onMyPropertyChanged: {
                    
        if (MyProperty &lt;100){
             model= ["15"];
              myComboBox.currentIndex = 0;
        }
       else {
            model=["15","27"];
            myComboBox.currentIndex = 1;
       }
}
</code></pre>
<p dir="auto">I'm seeing the correct choices in the menu after the property change happens, but the menu looks blank, as if index -1 has been chosen. If I print the currentText for the comboBox, it reports the correct choice is selected, but it's not showing.</p>
<p dir="auto">Is there some sort of refresh that needs to happen in order to see the correct index showing?</p>
]]></description><link>https://forum.qt.io/topic/98042/problems-setting-combobox-currentindex</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 20:04:22 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/98042.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Dec 2018 22:35:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problems setting ComboBox currentIndex on Sun, 30 Dec 2018 18:57:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/igor_stravinsky">@<bdi>igor_stravinsky</bdi></a> hi,</p>
<p dir="auto">you don't need to refresh, i just tested this and it works a expected</p>
<pre><code>Window {
    visible: true
    width: 640
    height: 480
    property bool tgl:false

    onTglChanged: {
        combo.model = ["1111","2222","3333"]
        combo.currentIndex=2;
    }

    ComboBox {
        id:combo
        editable: true
        model:["11","22","33"]
    }

    Button{
        anchors.centerIn: parent
        onClicked: tgl = !tgl
        text:"combo index : " + combo.currentIndex
    }
}
</code></pre>
]]></description><link>https://forum.qt.io/post/502052</link><guid isPermaLink="true">https://forum.qt.io/post/502052</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Sun, 30 Dec 2018 18:57:59 GMT</pubDate></item></channel></rss>