Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Model/View data access
HojjatJafary last edited by
The data access interfaces in the
QAbstractItemModelclass force the subclasses to use
QVariantwhen getting/setting data to the model.
There are two ways to access the internal data of my model:
Q_DECLARE_METATYPEmacro for all of my internal data classes so they can be used with
- Add my custom data access methods. (custom get/set functions).
Which one is reasonable with the expected use of Qt Model/View.
VRonin last edited by VRonin
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.
Classes that include the
Q_GADGETmacro are already registered metatypes so you can go down that route as well