Qt5.6: TreeView not updating?



  • Hello!

    I am aware that Qt5.6 is currently in alpha, but I need the "setRootIndex()" method for my project. My problem is that the view is not updating (only if I close the treebranch and reopen it, I can see the changed value). I am pretty sure that I implemented the model correctly and was wondering, if this is a known issue?

    Here's some code:

    The View:

    @
    TreeView {
    id: treeView

    anchors.fill: parent
    anchors.margins: 1
    headerVisible: false
    backgroundVisible: false
    alternatingRowColors: false
    frameVisible: false
    
    model: treeModel
    
    selection: ItemSelectionModel {
        model: treeModel
    }
    
    TableViewColumn {
        role: "baseName"
    }
    

    }
    @

    I hand the new data over to C++ and do:

    @
    m_model->setData(m_index, m_newName, TreeModel::BaseNameRole);
    @

    In the model:

    @
    bool TreeModel::setData(const QModelIndex &index, const QVariant &value, int role)
    {
    if (!index.isValid())
    return false;

    TreeItem* item = getItem(index);
    
    switch (role)
    {
    case BaseNameRole:
    	item->setBaseName(value.toString());
    	break;
    
    case ValueRole:
    	item->setValue(value);
    	break;
    
    case MetaDataRole:
    	item->setMetaData(value.toMap());
    	break;
    }
    
    emit dataChanged(index, index);
    
    return true;
    

    }
    @

    Still, the changes do not show up until I open and close the treebranch. Is this a bug in the TreeView?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.