Why my own type can not be declared but I used Q_DECLARE_METATYPE?

60 views Asked by At

I have a problem with Q_DECLARE_METATYPE:

Severity Code Description Project File Line Suppression State Error C2280 'MyNamespace::MyClass::MyClass(const MyNamespace::MyClass&)': attempting to reference a deleted function BksMtRisk C:\qt2\5.15.2\msvc2019_64\include\QtCore\qmetatype.h 825

What is wrong?

namespace MyNamespace {
class MyClass : public AbstractMyClass
{
 
}
}
Q_DECLARE_METATYPE(MyNamespace::MyClass)
1

There are 1 answers

2
Rawen On

From the Qt documentation Q_DECLARE_METATYPE(Type):

This macro makes the type Type known to QMetaType as long as it provides a public default constructor, a public copy constructor and a public destructor. It is needed to use the type Type as a custom type in QVariant.

So my guess is that your base class is missing one of the required Public Constructors

For more information read this: https://stackoverflow.com/a/31266254