I need to pass QSqlRecord to and from QVariant throughout my project. For this, I added
Q_DECLARE_METATYPE(QSqlRecord);
in .h class files requiring casting. I also have a base class from which several children inherit, in this case I assume that it is enough to include Q_DECLARE_METATYPE only once in the base class. Therefore, I have, for example:
- widgetBaseClass: declares a metatype
- widgetChildClass1: inherits widgetBaseClass does not declare a metatype
- widgetChildClass2: inherits widgetBaseClass does not declare a metatype
- myTableModel: declares a metatype
When I try to run such a program, I get
Redefinition of 'QMetaTypeId<QSqlRecord>
from widgetBaseClass, pointing to the previous declaration in myTableModel. If, on the other hand, I delete the declaration I receive:
static_assert failed "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt meta-object system");
, Q_DECLARE_METATYPE, , , , - , , QVariant, QVariant, ?