//!Qt源代码中的[0]

//! [0] in Qt source code

本文关键字:Qt 源代码      更新时间:2023-10-16

Qt示例项目中C++/QML源中的//! [n]n=0,1,2…)标记的含义是什么?

例如:

//! [0]
GLWidget::GLWidget(Helper *helper, QWidget *parent)
    : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), helper(helper)
{
    elapsed = 0;
    setFixedSize(840, 400);
    setAutoFillBackground(false);
}
//! [0]
//! [1]
void GLWidget::animate()
{
    elapsed = (elapsed + qobject_cast<QTimer*>(sender())->interval()) % 1000;
    repaint();
}
//! [1]
//! [2]
void GLWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter;
    painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);
    helper->paint(&painter, event, elapsed);
    painter.end();
}
//! [2]

尽管有常见的误解,但这是qdoc语法,而不是doxygen。此注释用于Qt项目中的文档目的,以标记要呈现的示例代码段。请参阅文档和实现此功能的相应代码。

作为Qt的最终用户,你不需要过多地处理它,除非你开始为Qt项目本身做出贡献,或者你正试图为自己的项目重用qdoc,这在这一点上是不可否认的奇怪。