Reputation:
This is my Container class.Which i declare in Q_DECLARE_METATYPE.
class Container
{
private:
std::string stdstrContainerName;
std::string stdstrPluginType;
Geometry Geom;
public:
Container();
Container(std::string, std::string, const Geometry& geometry );
Container(const Container& obj);
};
Q_DECLARE_METATYPE(Container)
This class is a the data member in TreeItem.Since this is heavy object so i want to pass it as a pointer rather than a value.
class TreeItem
{
Container* data();
private:
QList<TreeItem*> childItems;
Container itemData;
TreeItem* parentItem;
};
Container* TreeItem::data()
{
return &itemData;
}
I get compiler error that Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
Upvotes: 1
Views: 1299
Reputation:
If it is a pointer you want to pass around, you need to tell MOC about that:
Q_DECLARE_METATYPE(Container*)
Upvotes: 2