You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to register types that are member of other classes that have property read/write calls? For instance -
class MyClass : public QObject
{
CS_OBJECT(MyClass)
public:
enum Color { Red, Green, Blue };
CS_PROPERTY_READ(color, color)
CS_PROPERTY_WRITE(color, setColor)
Color color() const { return mColor; }
void setColor(Color color) { mColor = color; }
};
CS_DECLARE_METATYPE(MyClass::Color)
This implementation fails to build. The error is something along this line -
error C2908: explicit specialization; 'const QString &cs_typeToName<R>(void)' has already been instantiated
The problem is that CS_PROPERTY_READ (and CS_PROPERTY_WRITE) both call cs_typeToName and so the compiler ends up adding the default implementation for Color. Adding an explicit declaration for the same type after the class declaration results in this error. Note that for classes that don't have these properties (or something else implicitly adding the default implementation), an explicit declaration is still required.
Is this understanding correct? Is there a better way to implement this where it is not left to the compiler to report when I should and when I shouldn't need an explicit declaration?
The text was updated successfully, but these errors were encountered:
How to register types that are member of other classes that have property read/write calls? For instance -
This implementation fails to build. The error is something along this line -
The problem is that
CS_PROPERTY_READ
(andCS_PROPERTY_WRITE
) both callcs_typeToName
and so the compiler ends up adding the default implementation forColor
. Adding an explicit declaration for the same type after the class declaration results in this error. Note that for classes that don't have these properties (or something else implicitly adding the default implementation), an explicit declaration is still required.Is this understanding correct? Is there a better way to implement this where it is not left to the compiler to report when I should and when I shouldn't need an explicit declaration?
The text was updated successfully, but these errors were encountered: