topaz23
topaz23

Reputation: 11

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

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)

Upvotes: 0

Views: 87

Answers (1)

Rawen
Rawen

Reputation: 96

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

Upvotes: 1

Related Questions