no header providing "Q_OBJECT" is directly included
-
Hi,
I use Qt Creator 18.0.1 and Qt 6.10.1 to compile my project. In Qt Creator I get the following warningcommand-controller.h:41:4: no header providing "Q_OBJECT" is directly included [misc-include-cleaner]But in my code I includ <QObject>.
#ifndef COMMAND_CONTROLLER_H #define COMMAND_CONTROLLER_H // Includes //--------------------------------------------------------------------------------------------------------------------- // own header // other includes #include "framework/command.h" #include "navigation-controller.h" #include "sp-new.h" #include "sp.h" #include "wm-lib_global.h" // system includes #include <QObject> #include <QList> #include <QtQml/QQmlListProperty> // Macros/Defines //---------------------------------------------------------------------------------------------------------------------- // Forward declarations //---------------------------------------------------------------------------------------------------------------------- using namespace Framework; namespace Controllers { class WMLIBSHARED_EXPORT CommandController : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty<Framework::Command> uiEditViewContextCommands READ uiEditViewContextCommands CONSTANT) Q_PROPERTY(QQmlListProperty<Framework::Command> uiImageViewContextCommands READ uiImageViewContextCommands CONSTANT) Q_PROPERTY(QQmlListProperty<Framework::Command> uiFindViewContextCommands READ uiFindViewContextCommands CONSTANT) Q_PROPERTY(QQmlListProperty<Framework::Command> uiSpMapViewContextCommands READ uiSpMapViewContextCommands CONSTANT) Q_PROPERTY(QQmlListProperty<Framework::Command> uiNewViewContextCommands READ uiNewViewContextCommands CONSTANT) Q_PROPERTY(QQmlListProperty<Framework::Command> uiImageAddContextCommands READ uiImageAddContextCommands CONSTANT)How can I avoid this warnings?
Thank you for your help
BR
Martin -
C Christian Ehrlicher moved this topic from General and Desktop
-
Hi @msauer751,
I can't reproduce this with Creator 18.0.1 and Qt 6.10.2.
The patch release difference shouldn't be the reason.At first, please try including the Qt stuff first. Maybe some of the project specific includes already hit the pragma, making
#include <QObject>toothless.Maybe the include path is broken. You could check this by double clicking on the
QObjectinclude statement and see where you land.As a last resort, you can try to
#include <qobjectdefs.h>directly. Hammer-fix, a kitten will die.