Why is there QVariant(const QModelIndex &) constructor and not QVariant(const QPersistentModelIndex &) one?



  • The documentation of QModelIndex says: "Model indexes should be used immediately and then discarded. You should not rely on indexes to remain valid after calling model functions that change the structure of the model or delete items. If you need to keep a model index over time use a QPersistentModelIndex. "
    What good is a QVariant for keeping a QModelIndex? And why there is no QVariant for keeping QPersistentModelIndex?


  • Moderators

    i can't answer your question why there is no such constructor, but you may want to report a "feature request":https://bugreports.qt-project.org/?

    Nevertheless the missing of this constructor doesn't prevent you from using QPersistentModelIndex in QVariant...


Log in to reply
 

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