本文整理汇总了C++中QNetworkReply::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::isOpen方法的具体用法?C++ QNetworkReply::isOpen怎么用?C++ QNetworkReply::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::isOpen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isOpen
bool QNetworkReplyProto::isOpen() const
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->isOpen();
return false;
}
示例2: imgurImageUrl
// Finished uploading an image
void ShareOnline::Imgur::uploadFinished() {
// The sending network reply
QNetworkReply *reply = (QNetworkReply*)(sender());
// The reply is not open when operation was aborted
if(!reply->isOpen()) {
emit imgurImageUrl("");
emit finished();
return;
}
// Read output from finished network reply
QString resp = reply->readAll();
// Delete sender object
reply->deleteLater();
// If there has been an error...
if(resp.contains("success=\"0\"")) {
if(debug) {
QString errorMsg = resp.split("<error>").at(1).split("</error>").at(0);
LOG << CURDATE << QString("ERROR! An error occured. Error message: %1").arg(errorMsg).toStdString() << NL;
}
emit finished();
return;
}
// If data doesn't contain a valid link, something went wrong
if(!resp.contains("<link>") || !resp.contains("<deletehash>")) {
if(debug)
LOG << CURDATE << QString("ERROR! Invalid return data received: %1").arg(resp).toStdString() << NL;
emit finished();
return;
}
// Read out the link
QString imgLink = resp.split("<link>").at(1).split("</link>").at(0);
QString delHash = resp.split("<deletehash>").at(1).split("</deletehash>").at(0);
// and tell the user
emit imgurImageUrl(imgLink);
emit imgurDeleteHash(delHash);
emit finished();
}
示例3: downloadProgress
// creates a total download progress for multiple QNetworkReplies
void SettingsDialog::downloadProgress(qint64 received, qint64 total)
{
// Don't show progress for non-docset pages
if (total == -1 || received < 10240)
return;
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (!reply || !reply->isOpen())
return;
if (reply->property(DownloadTypeProperty).toInt() == DownloadDocset) {
const QString docsetName = reply->property(DocsetNameProperty).toString();
QTemporaryFile *tmpFile = m_tmpFiles[docsetName];
if (!tmpFile) {
tmpFile = new QTemporaryFile(this);
tmpFile->open();
m_tmpFiles.insert(docsetName, tmpFile);
}
tmpFile->write(reply->read(received));
}
// Try to get the item associated to the request
QListWidgetItem *item
= ui->availableDocsetList->item(reply->property(ListItemIndexProperty).toInt());
if (item)
item->setData(ProgressItemDelegate::ValueRole, percent(received, total));
qint64 previousReceived = 0;
const QVariant previousReceivedVariant = reply->property(DownloadPreviousReceived);
if (!previousReceivedVariant.isValid())
m_combinedTotal += total;
else
previousReceived = previousReceivedVariant.toLongLong();
m_combinedReceived += received - previousReceived;
reply->setProperty(DownloadPreviousReceived, received);
displayProgress();
}