QTreeView/Model drop action - no expand sign ?



  • Hey

    I'm lost :- ), I started with QAbstractItemModel and QTreeView, subclassed what I needed, when I drop item on another item the expand signal does not appear. I have to expand all/hide all to force it to update the icon drawing...

    I call beginInsertRows()/end as well as Q_EMIT(itemFirst.index(),itemLast.index()) when finishing dropMimeData to notify views of data change but I still have no ">" when I finish the drop...

    What should I do ?

    Edit it seems that even if I add items to invisibleRoot they don't display either until I force refresh somehow...

    Regards
    Dariusz
    TIA


  • Moderators

    @Dariusz said in QTreeView/Model drop action - no expand sign ?:

    call beginInsertRows()/end as well as Q_EMIT(itemFirst.index(),itemLast.index()) when finishing dropMimeData to notify views of data change but I still have no ">" when I finish the drop...
    What should I do ?

    to the expand icon appear either QAbstractItemModel::canFetchMore() returns true or QAbstractItemModel::rowCount() a value bigger 0 for the parent index.
    Also did you emit the dataChanged() signal on the parent index?



  • @raven-worx said in QTreeView/Model drop action - no expand sign ?:

    Also did you emit the dataChanged() signal on the parent index?

    I've just read the post. I forgot to correct it. This is what I edit:

    bool testModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) {
         ...
         Q_EMIT dataChanged(itemFirst.index(),itemLast.index()) 
    }
    

    Hmmmm so I tried this, the parent is the object that is in function above.

        Q_EMIT dataChanged(parent, parent)
    

    Now this now "magically" works, I get extra ">" when I drop item on another item...
    I also learned that I also need to call Q_EMIT layoutChanged({parent}/flag) to update view if I drop items on expanded parent...

    Ok all good then, thanks! Weird issue o.o



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