Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Class contains Q_OBJECT macro error ?

Class contains Q_OBJECT macro error ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 637 Views
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 9 Feb 2023, 15:04 last edited by Anonymous_Banned275 2 Sept 2023, 15:33
    #1

    Class contains Q_OBJECT macro ....

    why am I getting the error - basically missing inheritance.

    I do follow the QtCreator "add class ....

    If that is not sufficient , how do I add inheritance using SAME "add class" .
    It looks as I have to use anther process to add the inheritance...

    Not sure it can be used when the initial "build class " is not completed.

    /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/JAN21/BLUETOOTH/SOURCE/CCC_SOURCE/configuration.h:8: error: Class contains Q_OBJECT macro but does not inherit from QObject

    #ifndef CONFIGURATION_H
    #define CONFIGURATION_H

    #include <QObject>

    class Configuration
    {
    Q_OBJECT
    public:
    Configuration();
    };

    #endif // CONFIGURATION_H
    #ifndef CONFIGURATION_H
    #define CONFIGURATION_H

    #include <QObject>

    class Configuration
    {
    Q_OBJECT
    public:
    Configuration();
    };

    #endif // CONFIGURATION_H

    8b06eda7-5312-43c6-b952-f9572fdac7c6-image.png

    SOLVED
    For unknown reason my initial usage of "Define Class" had the <Custom> option grayed out / disabled .

    deb9011a-729a-4660-bc11-2434b69c741e-image.png

    C 1 Reply Last reply 9 Feb 2023, 15:09
    0
    • A Anonymous_Banned275
      9 Feb 2023, 15:04

      Class contains Q_OBJECT macro ....

      why am I getting the error - basically missing inheritance.

      I do follow the QtCreator "add class ....

      If that is not sufficient , how do I add inheritance using SAME "add class" .
      It looks as I have to use anther process to add the inheritance...

      Not sure it can be used when the initial "build class " is not completed.

      /mnt/07b7c3f8-0efb-45ab-8df8-2a468771de1f/PROJECTS/JAN21/BLUETOOTH/SOURCE/CCC_SOURCE/configuration.h:8: error: Class contains Q_OBJECT macro but does not inherit from QObject

      #ifndef CONFIGURATION_H
      #define CONFIGURATION_H

      #include <QObject>

      class Configuration
      {
      Q_OBJECT
      public:
      Configuration();
      };

      #endif // CONFIGURATION_H
      #ifndef CONFIGURATION_H
      #define CONFIGURATION_H

      #include <QObject>

      class Configuration
      {
      Q_OBJECT
      public:
      Configuration();
      };

      #endif // CONFIGURATION_H

      8b06eda7-5312-43c6-b952-f9572fdac7c6-image.png

      SOLVED
      For unknown reason my initial usage of "Define Class" had the <Custom> option grayed out / disabled .

      deb9011a-729a-4660-bc11-2434b69c741e-image.png

      C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 9 Feb 2023, 15:09 last edited by
      #2

      @AnneRanch said in Class contains Q_OBJECT macro error ?:

      Class contains Q_OBJECT macro but does not inherit from QObject

      This error message tells you exactly where the problem is - you added Q_OBJECT but do not derive from QObject.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • C Christian Ehrlicher moved this topic from C++ Gurus on 9 Feb 2023, 15:37

      1/2

      9 Feb 2023, 15:04

      • Login

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