本文整理汇总了C++中QNetworkReply::operation方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::operation方法的具体用法?C++ QNetworkReply::operation怎么用?C++ QNetworkReply::operation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::operation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operation
QNetworkAccessManager::Operation QNetworkReplyProto::operation() const
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->operation();
return QNetworkAccessManager::HeadOperation;
}
示例2: requestVerb
QByteArray requestVerb(const QNetworkReply &reply)
{
switch (reply.operation()) {
case QNetworkAccessManager::HeadOperation:
return "HEAD";
case QNetworkAccessManager::GetOperation:
return "GET";
case QNetworkAccessManager::PutOperation:
return "PUT";
case QNetworkAccessManager::PostOperation:
return "POST";
case QNetworkAccessManager::DeleteOperation:
return "DELETE";
case QNetworkAccessManager::CustomOperation:
return reply.request().attribute(QNetworkRequest::CustomVerbAttribute).toByteArray();
case QNetworkAccessManager::UnknownOperation:
break;
}
return QByteArray();
}
示例3: error
void NetworkAccess::error(QNetworkReply::NetworkError code) {
// get the QNetworkReply that sent the signal
QNetworkReply *networkReply = static_cast<QNetworkReply *>(sender());
if (!networkReply) {
qDebug() << "Cannot get sender";
return;
}
networkReply->deleteLater();
// Ignore HEADs
if (networkReply->operation() == QNetworkAccessManager::HeadOperation)
return;
// report the error in the status bar
QMainWindow* mainWindow = static_cast<QMainWindow*>(qApp->topLevelWidgets().first());
if (mainWindow) mainWindow->statusBar()->showMessage(
tr("Network error: %1").arg(networkReply->errorString()));
qDebug() << "Network error:" << networkReply->errorString() << code;
}