本文整理汇总了C++中QNetworkReply::manager方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::manager方法的具体用法?C++ QNetworkReply::manager怎么用?C++ QNetworkReply::manager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkReply
的用法示例。
在下文中一共展示了QNetworkReply::manager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QNetworkAccessManager *QNetworkReplyProto::manager() const
{
QNetworkReply *item = qscriptvalue_cast<QNetworkReply*>(thisObject());
if (item)
return item->manager();
return 0;
}
示例2: OnLoggedIn
void LoginDialog::OnLoggedIn() {
QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
QByteArray bytes = reply->readAll();
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (status != 302) {
DisplayError("Failed to log in (invalid password or expired session ID? try re-logging with email/password pair or via steam)");
return;
}
QList<QNetworkCookie> cookies = reply->manager()->cookieJar()->cookiesForUrl(QUrl(POE_MAIN_PAGE));
for (auto &cookie : cookies)
if (QString(cookie.name()) == POE_COOKIE_NAME)
session_id_ = cookie.value();
// we need one more request to get account name
QNetworkReply *main_page = login_manager_->get(QNetworkRequest(QUrl(POE_MY_ACCOUNT)));
connect(main_page, SIGNAL(finished()), this, SLOT(OnMainPageFinished()));
}
示例3: loginResult
void Session::Request::onLoginPageResult() {
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (status != 302) {
emit loginResult(0x01, "Failed to log in (invalid password or expired session ID).");
}
else {
QList<QNetworkCookie> cookies = reply->manager()->cookieJar()->cookiesForUrl(MainUrl());
for (auto &cookie : cookies) {
if (QString(cookie.name()) == SessionIdCookie()) {
_sessionId = cookie.value();
emit loginResult(0x00, "Logged in!");
break;
}
}
QNetworkRequest request = createRequest(AccountUrl());
QNetworkReply *r = _manager->get(request);
connect(r, &QNetworkReply::finished, this, &Session::Request::Request::onAccountPageResult);
}
reply->deleteLater();
}