Unsolved Model/View data access
-
The data access interfaces in the
QAbstractItemModel
class force the subclasses to useQVariant
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 withQVariant
.
OR
- Add my custom data access methods. (custom get/set functions).
Which one is reasonable with the expected use of Qt Model/View.
- Use
-
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 theQ_GADGET
macro are already registered metatypes so you can go down that route as well