Search code examples
qtdoxygen

Doxygen update Class Detailed Description if Q_OBJECT present


Let's say I have the following class

/**
 * @brief Brief description
 *
 * Longer description
 */
class MyClass: public QObject {

    Q_OBJECT

public:
    /**
     * @brief CTOR
     */
    MyClass() = default;

    /**
     * @brief DTOR
     */
    virtual ~MyClass() = default;

   // Etcetera
};

When I go and generate the Doxygen documentation, then the appropriate documentation is generated, however it just ignores the Q_OBJECT by default. What I would want to accomplish is add some kind of indication to the class in the generated documentation to indicate that the class supports Qt Signals and Slots. I can use the PREDEFINED property to get Doxygen to replace that macro with something else

PREDEFINED = "Q_OBJECT=/// @note Supports Signals and Slots"

however this is then applied to the next subsequent element (the Constructor in this case) rather than the class itself. In my digging I've come across the < operator, however that only appears to work for fields and parameters, and not classes.

Is there some way of getting some kind of indication/marking in the class documentation to indicate that Q_OBJECT is present and the signals and slots would be supported, without relying on manually adding such a marker to the class comment?

Note: I'm using Doxygen version 1.11.0


Solution

  • When I use the following settings:

    QUIET = YES
    MACRO_EXPANSION = YES
    PREDEFINED = "QObject=QObject /** @note Supports Signals and Slots */"
    PREDEFINED += "Q_OBJECT="
    

    I get as a result: enter image description here

    (Note: current doxygen version is 1.13.2)