Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    2
    826
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      EmoBemo last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        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...

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • First post
          Last post