Skip to content
  • 1 Votes
    7 Posts
    2k Views
    H

    For the record, this was a perfectly good question. The QAbstractItemModel::createIndex() docs do not state that it embeds a model pointer into the index it creates, nor do the QModelIndex docs mention the private constructor that makes it possible.

    This makes QModelIndex::parent() look suspicious if you happen to be troubleshooting a problem. If you want to be sure your model is implemented correctly, you have to put aside the docs and dig up the inline function definitions in qabstractitemmodel.h.

  • 0 Votes
    116 Posts
    38k Views
    VRoninV

    Of course I'll cast my -1 vote as well.

    I'll add to point 1:

    If the data contained in the model is all of basic types or implicitly shared types then it's possible to already use the current framework without ever triggering any expensive* copy

    , to point 2:

    There's no clarity on how to support different types in different roles would we need an additional template argument for each used role beyond Qt::UserRole? is so the problems above grow exponentially with the roles

    And to point 3:

    No possible implementation for a reliable dataChanged emission if model internals are exposed directly

    *expensive = a copy that implies more that a:

    memcpy of less than 65bits and an increase/decrease of a numeric reference counter