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
5 Posts 3 Posters 145 Views 3 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 Offline
      Axel SpoerlA Offline
      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

      msauer751M 1 Reply Last reply
      0
      • Axel SpoerlA Axel Spoerl

        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.

        msauer751M Offline
        msauer751M Offline
        msauer751
        wrote last edited by
        #3

        Hi @Axel-Spoerl ,

        I have to add #include <qtmetamacros.h> to avoid this warning.

        BR
        martin

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          Hi,

          Then something is off. Including QObject should be enough.
          Which project management system are you using ? qmake or cmake ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          msauer751M 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Then something is off. Including QObject should be enough.
            Which project management system are you using ? qmake or cmake ?

            msauer751M Offline
            msauer751M Offline
            msauer751
            wrote last edited by
            #5

            Hi @SGaist

            cmake.

            And with CMakeLists.txt of the project

            cmake_minimum_required(VERSION 3.16)
            
            set(APP "qt_wm")
            set(VER "1.0")
            
            message("CMAKE fuer project: " ${APP})
            
            project(${APP} VERSION ${VER} LANGUAGES CXX)
            
            #set(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/_Build/Bin/${CMAKE_SYSTEM_NAME}/${CMAKE_BUILD_TYPE}")
            #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
            #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
            #set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
            set(LIBTYP "SHARED")
            set(CMAKE_CXX_STANDARD 23)
            set(CMAKE_CXX_STANDARD_REQUIRED ON)
            set(CMAKE_AUTOMOC ON)
            set(CMAKE_AUTORCC ON)
            set(CMAKE_AUTOUIC ON)
            set(CMAKE_INCLUDE_CURRENT_DIR ON)
            set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
            #set(CMAKE_CXX_CLANG_TIDY clang-tidy)
            
            if (WIN32)
                set(SSLDIR "E:/Qt/Tools/OpenSSLv3/Win_x64/bin/")
                set(SSLLIB1 "libcrypto-3-x64.dll")
                set(SSLLIB2 "libssl-3-x64.dll")
                message("    WIN32: SSLDIR=" ${SSLDIR})
                message("    WIN32: SSLLIB=" ${SSLLIB1} " " ${SSLLIB2})
            elseif (UNIX)
                #set(CMAKE_PREFIX_PATH "/opt/Entwicklung/Qt/6.10.1/gcc_64/")
            endif()
            
            add_subdirectory(library/lib-datad)
            add_subdirectory(library/lib-db)
            add_subdirectory(library/lib-geo)
            add_subdirectory(library/lib-jsonrpc)
            add_subdirectory(wm-lib)
            add_subdirectory(wm-ui)
            

            and of the subproject:

            cmake_minimum_required(VERSION 3.16)
            
            set(LIB "datad")
            set(LIBDEF "LIBDATAD_LIBRARY")
            
            message("CMAKE fuer project: lib" ${LIB})
            
            project(lib-${LIB} VERSION 1.0.0 LANGUAGES CXX)
            
            find_package(Qt6 COMPONENTS Core REQUIRED)
            find_package(Qt6 COMPONENTS Qml  REQUIRED)
            
            include_directories("source/")
            include_directories("source/helper")
            
            set(SOURCES
                source/data-decorator.cpp
                source/bool-decorator.cpp
                source/float-decorator.cpp
                source/int-decorator.cpp
                source/string-decorator.cpp
                source/enumerator-decorator.cpp
                source/dropdown.cpp
                source/helper/dropdown-value.cpp
                source/helper/koordinaten.cpp
                source/string_bool-decorator.cpp
                source/koordinaten-decorator.cpp
                source/attribute-decorator.cpp
            
                source/lib-datad_global.h
                source/data-decorator.h
                source/bool-decorator.h
                source/float-decorator.h
                source/int-decorator.h
                source/string-decorator.h
                source/enumerator-decorator.h
                source/dropdown.h
                source/helper/dropdown-value.h
                source/string_bool-decorator.h
                source/koordinaten-decorator.h
                source/attribute-decorator.h
                source/helper/koordinaten.h
            )
            
            add_library(${LIB} ${LIBTYP} ${SOURCES})
            
            target_link_libraries(
                ${LIB}
                    Qt6::Core
                )
            
            target_compile_definitions(${LIB} PRIVATE ${LIBDEF})
            target_compile_definitions(${LIB} PUBLIC "QT_DEPRECATED_WARNINGS")
            
            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