我见过在许多项目中,一些程序员在他们的代码中使用了//! [1]
,//! [2]
,...,//! [n]
,但我不知道这可能意味着什么。这个声明是什么//! [数字]是什么意思?
如果有人指出使用这些评论,我将不胜感激。 这是一个鹬代码:
BlockingClient::BlockingClient(QWidget *parent)
: QWidget(parent)
{
hostLabel = new QLabel(tr("&Server name:"));
portLabel = new QLabel(tr("S&erver port:"));
QString ipAddress;
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
for (int i = 0; i < ipAddressesList.size(); ++i) {
}
// if we did not find one, use IPv4 localhost
if (ipAddress.isEmpty())
ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
//...
connect(hostLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableGetFortuneButton()));
connect(portLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(enableGetFortuneButton()));
//! [0]
connect(&thread, SIGNAL(newFortune(QString)),
this, SLOT(showFortune(QString)));
//! [0] //! [1]
connect(&thread, SIGNAL(error(int,QString)),
this, SLOT(displayError(int,QString)));
//! [1]
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
setLayout(mainLayout);
setWindowTitle(tr("Blocking Fortune Client"));
portLineEdit->setFocus();
}
//! [2]
void BlockingClient::requestNewFortune()
{
getFortuneButton->setEnabled(false);
thread.requestNewFortune(hostLineEdit->text(),
portLineEdit->text().toInt());
}
//! [2]
//! [3]
void BlockingClient::showFortune(const QString &nextFortune)
{
if (nextFortune == currentFortune) {
requestNewFortune();
return;
}
//! [3]
//! [4]
currentFortune = nextFortune;
statusLabel->setText(currentFortune);
getFortuneButton->setEnabled(true);
}
//! [4]
看起来像某种doxygen doc评论。 – Rapptz
你可以举一个你已经看到完成的项目的例子吗? –
这就是编码的力量。 –