Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does //! [0] mean in Qt C++ example code?

Tags:

c++

qt

I've just opened a Qt server example source code. Here is one of the files: http://code.qt.io/cgit/qt/qtbase.git/tree/examples/network/fortuneserver/server.cpp

It has comments like //! [0]. Here's an example:

//! [3]
    connect(tcpServer, &QTcpServer::newConnection, this, &Server::sendFortune);
//! [3]

I've never seen them before. What do they mean?

like image 473
Giacomo Scarpino Avatar asked Oct 20 '25 13:10

Giacomo Scarpino


1 Answers

It is used in Qt for generating the web documentation from the source code. usually, wherever you find the //! [NUMBER], you will be able to see that piece of code in the web documentation. Also, it is found at the end of the code, so the documentation generator tool can know which portion of the code goes where.

Of course, the //! tags are found in the source code, but not in the generated documentation. Otherwise, the documentation would become unreadable.

Why they have used this? It begins with // (meaning it is a comment, so the compiler will ignore it), and they have added a "!" for the generator tool, so it can separate the code comments from the documentation info.

//![1] This line will be generated into the documentation explaining the following function
void somethingDifficult()
{
   //This would be a normal comment, so not exported to documentation
}
//![1] Here we mark the end of the export to the documentation
like image 169
LoPiTaL Avatar answered Oct 23 '25 04:10

LoPiTaL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!