Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Model/View data access
Forum Updated to NodeBB v4.3 + New Features

Model/View data access

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 198 Views 1 Watching
  • 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.
  • HojjatJafaryH Offline
    HojjatJafaryH Offline
    HojjatJafary
    wrote on last edited by
    #1

    The data access interfaces in the QAbstractItemModel class force the subclasses to use QVariant when getting/setting data to the model.

    There are two ways to access the internal data of my model:

    • Use Q_DECLARE_METATYPE macro for all of my internal data classes so they can be used with QVariant.

    OR

    • Add my custom data access methods. (custom get/set functions).

    Which one is reasonable with the expected use of Qt Model/View.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      Add my custom data access methods. (custom get/set functions).

      This also requires the delegate to get tied up with the model.

      I'm a fan of solution 1 but, in the interest of pragmatism, I'd say use the path that is less painful to implement for you.

      P.S.
      Classes that include the Q_GADGET macro are already registered metatypes so you can go down that route as well

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved