Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Signal flag changes for QAbstractItemModel


  • Qt Champions 2017

    Hello,
    How do we signal item flags being changed for an item in the model?

    I have a model that's working over a network layer and I get unsolicited notifications for some of the items. What I need is to signal the view that a given item (or range of items) was disabled. However I don't see any signal or method that I'm supposed to call to achieve this.
    Should I raise dataChanged instead?



  • @kshegunov Hi,

    If by "disabled" you mean that your item is still in the model, didn't have moved, so I would say yes, dataChanged is the right signal to call, with the corresponding indexes in arguments.


  • Qt Champions 2017

    Yes, the item is still in the model and hasn't moved. What I want is to tell the view that it needs to call QAbstractItemModel::flags (which is going to return the flags with Qt::ItemIsEnabled bit removed) again for some range of items. If a role was changed then dataChanged would've been the correct way to do it that's clear enough, but the model interface doesn't have anything to signal changes for the item flags specifically as far as I can tell.


  • Lifetime Qt Champion

    Hi,

    AFAIK, the flags are check "on use" so if you double click on an item which you just changed flags for not editable it should already take it into account.


Log in to reply