I have a small class describing an object which I want to use in a QAbstractItemModel. It's not derived from anything, has a copy and a default constructor and at the end, I'm adding the Q_DECLARE_METATYPE macro which should - per Qt documentation - be sufficient to use the class as a QVariant.
Qt Code:
class Dataset { Dataset(); Dataset(const Dataset& _data); ~Dataset(); ... } Q_DECLARE_METATYPE(Dataset)To copy to clipboard, switch view to plain text mode
Here's how I use the class:
Qt Code:
... QVariant var; Dataset data; var.setValue(data); ...To copy to clipboard, switch view to plain text mode
When trying to compile, I get the following output/error message:
/usr/include/QtCore/qmetatype.h(169): error: class "QMetaTypeId<Dataset *>" has no member "qt_metatype_id"
static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
^
detected during:
instantiation of "int QMetaTypeId2<T>::qt_metatype_id() [with T=Dataset *]" at line 230
instantiation of "int qMetaTypeId(T *) [with T=Dataset *]" at line 463 of "/usr/include/QtCore/qvariant.h"
instantiation of "void qVariantSetValue(QVariant &, const T &) [with T=Dataset *]" at line 528 of "/usr/include/QtCore/qvariant.h"
instantiation of "void QVariant::setValue(const T &) [with T=Dataset *]" at line 21 of "/home/user/projects/playground/source/Shared/GUI/DatasetTreeModel.cpp"
Any help is greatly appreciated!
Bookmarks