Simple question : What is //! [0] ...etc in the editor?
-
When i look at the mainwindows.cpp file of the dockwidgets example, I see the following which has //! [0] and so forth......what are these and what do they do?:
//! [0] <<<<<<------------------------------------------------------------WHAT IS THIS?
#include <QtWidgets>
#ifndef QT_NO_PRINTDIALOG
#include <QtPrintSupport>
#endif#include "mainwindow.h"
//! [0] <<<<<<--------------------------------------------------------------WHAT IS THIS?//! [1] <<<<<<--------------------------------------------------------------WHAT IS THIS?
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);createActions(); createMenus(); createToolBars(); createStatusBar(); createDockWindows(); setWindowTitle(tr("Dock Widgets")); newLetter(); setUnifiedTitleAndToolBarOnMac(true);
}
//! [1] -
First of all, they're comments. They start with "//", so all C++ compilers ignore those lines.
Secondly, they're documentation comments. Special tools like "Doxygen":http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html#cppblock and Qt's internal "QDoc":http://qt-project.org/doc/qt-5.1/qdoc/01-qdoc-manual.html will interpret "//!" as documentation markers.
In this example, you're looking at "code snippets":http://qt-project.org/doc/qt-5.1/qdoc/07-0-qdoc-commands-includingexternalcode.html#snippet: When QDoc sees those markers, it will copy the marked code into other documentation articles. "//! [0]" marks the start/end of a snippet labelled "0"; "//! [1]" marks the start/end of a snippet labelled "1", and so on.
You can see the result of your example at "here":http://qt-project.org/doc/qt-5.1/qtwidgets/mainwindows-dockwidgets.html