Hi Everyone i have a foo class
Code in foo.h
namespace GUI
{
class Foo : public QObject
{
Q_OBJECT
public:
explicit Foo(QObject *parent = 0);
virtual ~Foo();
....
};
}
Now this is working and compiling fine but i want to save this custom c++ class using QSettings and one of the step is registering your class with Q_DECLARE_METATYPE
and therefore as soon as i put this line
Q_DECLARE_METATYPE(Foo)
at the end of my foo.h file i get these compiler error C2248:'QObject::Qobject':cannot access private member declared in class 'QObject' and which when clicked only takes me to last line of my connection.h header file and gives no other information as to what might be wrong i,e the error point me to
Class Foo
{
};<---- point me here
Q_DECLARE_METATYPE(Foo)
I know that QObject cannot be copied and this is related to it but i have no idea what maybe wrong here and how can i rectify it. Thanks in advance
Make sure your
Q_DECLARE_METATYPE
statement is outside of your namespace and that you fully qualify your class name. See theQ_DECLARE_METATYPE
doc for more detail.