本文介绍了如何脱氧评论Qt属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Q_PROPERTY上附加Doxygen注释.

I would like to attach Doxygen comments to my Q_PROPERTYs.

例如:

song.h

class Song : public QObject
{
    Q_OBJECT

private:
    Q_PROPERTY(QString title READ title WRITE setTitle);
    QString _title;

public:
    QString title() const;
    void setTitle(const QString& value);
};

song.cpp

#include "song.h"

Song::Song(QObject *parent) :
    QObject(parent)
{
}

QString Song::title() const { return _title; }

void Song::setTitle(const QString &value) { _title = value; }

我如何告诉Doxygen title是Qt Meta-Object系统中的一个属性,而title()和setTitle()是访问器函数?我想获得与类似的输出..>

How can I tell Doxygen that title is a property in the Qt Meta-Object system and title() and setTitle() are the accessor functions? I would like to achieve a similar output to this.

推荐答案

我终于找到了一种方法.

I have finally found a way to do this.

  • 在源文件中:

  • In the source files:

/**
 * @brief The name of the user.
 * @accessors name(), setName()
 */
Q_PROPERTY(QString name READ name WRITE setName)

  • Doxyfile 中:

    ALIASES = "accessors=\par Accessors:\n"
    

  • 我所做的是定义一个别名,该别名将生成标题为"Accessors:"的段落,后跟引用的方法.

    What I've done is define an alias named "accessors" that will generate a paragraph with the title "Accessors:" followed by the referenced methods.

    这是文档中的样子:

    提示:如果属性的名称与读取属性的方法相同,则可能需要在文档中访问者的名称前加上'"(否则访问器将显示为指向自身的链接):

    Tip: if the name of the property is the same as the method for reading the property, you may want to precede the accessor's name in the documentation by a '%' (otherwise the accessor will be displayed as a link that points to itself):

    /**
     * ...
     * @accessors %name(), setName()
     * ...
     */
    

    这篇关于如何脱氧评论Qt属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-24 03:49