Qt - Q_OBJECT vs. #include <QObject>
No. You need Q_OBJECT in defining the class of things in which you want to include signals / slots, in addition to including the correct headers.
From QObject api docs :
Note that the Q_OBJECT macro is required for any object that implements signals, slots, or properties. You also need to run the Meta Object Compiler on the source file. We strongly recommend that you use this macro in all subclasses of QObject, regardless of whether they actually use signals, slots, or properties, as failure to do this can lead certain functions to strange behavior.
Just check out the various examples in the Qt documentation for more details and sample code. The Signals and Slots link is a good place to view. Also see the Object Model link.
They are used for two different purposes.
Q_OBJECT :
The Q_OBJECT mask should appear in the private section of the class definition, which declares its own signals and slots or uses other services provided by the Qt meta-object system.
If you want to use signals, slots and other functions of a meta object, you need to have a Q_OBJECT macro.
#include<QObject> :
Used to include the qobject.h header file, so you can use the functions available in the QObject class .. Let's say, for example, QObject::connect() .
And to use the Q_OBJECT macro Q_OBJECT you must #include <QObject> .
No. You add this macro to classes derived from QObject . But you still need headlines, as Mats says! See http://doc.qt.io/qt-5/qobject.html#Q_OBJECT