BeginInsertRow/EndInsertRow/BeginRemoveRow etc - keeps resetting expanded items states?



  • Hey

    So I'm working on QAbstractItemModels to build up QTreeView. I'm hand managing all the insert/remove/append/remove rows. I initially built it "as is " and lately I read up that I need to add begin/end routines before and after inserting rows. Now without it, it seemed to work fine, but now with it whenever I drag/drop items, the expanded items close down and so on, entire views gets reset. Is that normal? How can I preserve expanded items or am I doing something wrong?

    For example, if I have

        nodeA->appendItem(someNode);
        appendItem(myNode *node){
            if(model){
                model->beginInsertingRows()
            }
            children.push_back(node)
            if(model){
                model->endInsertingRows()
            }
        }
    

    This is routine more or less, but these model-> signals keeps reseeting my expanded items? Or do we dont use these signals if we use our own drag/drop/model/view etc?


Log in to reply
 

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