我在许多项目中看到一些程序员在他们的代码中使用//! [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]