The Q_OBJECT macro can be put in public, protected or private section and it will do the same. It doesn't matter for moc but I highly recommend to always put it at the top of your class for the following reason:
The Q_OBJECT macro is defined like this:
#define Q_OBJECT \
public: \
//stuff... \
private: \
//other stuff...
So it's easy to make your other members private by mistake like this:
class Foo
{
public:
Q_OBJECT
int bar; //oh no! bar is private
};
If you put the macro at the top it won't affect access declarations below:
class Foo
{
Q_OBJECT
public:
int bar; //yes! bar is public as intended
};