Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. no header providing "Q_OBJECT" is directly included
Forum Updated to NodeBB v4.3 + New Features

no header providing "Q_OBJECT" is directly included

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 49 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • msauer751M Offline
    msauer751M Offline
    msauer751
    wrote last edited by
    #1

    Hi,
    I use Qt Creator 18.0.1 and Qt 6.10.1 to compile my project. In Qt Creator I get the following warning

    command-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

    1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher moved this topic from General and Desktop
    • Axel SpoerlA Online
      Axel SpoerlA Online
      Axel Spoerl
      Moderators
      wrote last edited by
      #2

      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 QObject include statement and see where you land.

      As a last resort, you can try to #include <qobjectdefs.h> directly. Hammer-fix, a kitten will die.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved