[SailfishDevel] [bug] Silica ComboBox.qml - can't set currentIndex after initialization

Raine Mäkeläinen raine.makelainen at jolla.com
Mon Jan 5 10:33:56 UTC 2015

Hi Michal,

Thanks for the report! Filed a bug and wrote an example [1] that has currentIndex set and appends model dynamically. Hope that it helps in your case.


Lähettäjä: devel-bounces at lists.sailfishos.org [devel-bounces at lists.sailfishos.org] käyttäjän ok1hlm at centrum.cz [ok1hlm at centrum.cz] puolesta
Lähetetty: 29. joulukuuta 2014 16:45
Vastaanottaja: devel at lists.sailfishos.org
Kopio: Developer Care
Aihe: [SailfishDevel] [bug] Silica ComboBox.qml - can't set currentIndex after initialization


I've found a bug in ComboBox.qml used in Jolla phone. I wrote an application using pyotherside. During initialization, it populates combobox and sets the currentIndex to saved value. The problem is, that setting the currentIndex does nothing.

ComboBox.qml uses weird timer to delay some tasks. When you change currentIndex before that timer is triggered, it ignores the change.

Connections {
    target: comboBox.menu ? comboBox.menu._contentColumn : null
    onChildrenChanged: {
        // delay the reload in case there are more children changes to come
        if (!updateCurrentTimer.running) {
            _updating = true


onCurrentIndexChanged: {
    _currentIndexSet = true
    if (_completed && !_updating) {
        _updating = true
        _updateCurrent(currentIndex, null)
        _updating = false

My application does something like:

function foo(result) {
  for(var i=0; i<result.length; ++i)
    combolistmodel.append({index:i, text:result[i]});
// comboid._updating = 0; // REQUIRED WORKAROUND

Whey I force the _updating to 'false', it works. Also if I set the correntIndex in a timer some time later, it works.

I've tested following workaround:

onCurrentIndexChanged: {
    _currentIndexSet = true
    if (_completed) {
      if (updateCurrentTimer.running) {
        var save_currentIndex = currentIndex;
        currentIndex = save_currentIndex;
      if (!_updating) {
        _updating = true
        _updateCurrent(currentIndex, null)
        _updating = false

But it still seems odd to me to use a timer in in a combobox.

Whole reproducer: http://fpaste.org/164044/59940141/
Code causing this problem: http://fpaste.org/163881/97171141/
Tested workaround: http://fpaste.org/164045/85997614/

SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org

More information about the Devel mailing list