Atomic_Sheep
15th May 2012, 15:19
Hi guys, I'm playing around with composition and inheritance for the first time and I'm hitting a bit of a problem.
From my understanding, to be able to have an object emit a signal and receive signals i.e. for that it must have slots, it must inherit QObject.
So I created my own class and included the Q_OBJECT macro:
class Button : public QObject
{
Q_OBJECT
However, I would also like this button to include other classes which outline the button position and other attributes in their own classes. When I created the initialiser list in the header file, the variables which I assigned to the Button members explicitly i.e. after the : symbol, spit out an error upon building...
'position' was not declared in this scope.
How do I solve this problem?
I tried simply adding my initialiser list after the
Button::Button(QObject *parent) :
QObject(parent)
but that didn't work.
From my understanding, to be able to have an object emit a signal and receive signals i.e. for that it must have slots, it must inherit QObject.
So I created my own class and included the Q_OBJECT macro:
class Button : public QObject
{
Q_OBJECT
However, I would also like this button to include other classes which outline the button position and other attributes in their own classes. When I created the initialiser list in the header file, the variables which I assigned to the Button members explicitly i.e. after the : symbol, spit out an error upon building...
'position' was not declared in this scope.
How do I solve this problem?
I tried simply adding my initialiser list after the
Button::Button(QObject *parent) :
QObject(parent)
but that didn't work.