-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.cpp
38 lines (34 loc) · 1.24 KB
/
helper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "helper.h"
#include <QDebug>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QStandardPaths>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QNetworkCookie>
#include <QNetworkAccessManager>
#include "networkaccessmanager.h"
//#include "cookiejar.h"
#include "webkitcookiejar.h"
Helper::Helper(QObject *parent) :
QObject(parent)
{
}
void Helper::onLoadMe() {
// NetworkAccessManager *s_networkAccessManager = new NetworkAccessManager();
// s_networkAccessManager->setCookieJar(new CookieJar);
// engine->networkAccessManager()->setCookieJar(new WebKitCookieJar);
QUrl url("http://hashtock.appspot.com/api/?format=json");
QNetworkRequest req(url);
// QNetworkReply *resp = s_networkAccessManager->get(req);
QNetworkReply *resp = engine->networkAccessManager()->get(req);
connect(resp, SIGNAL(finished()), this, SLOT(slotReadReady()), Qt::UniqueConnection);
}
void Helper::slotReadReady()
{
QNetworkReply *resp = qobject_cast<QNetworkReply *>(sender());
qDebug() << "Rep: " << resp->readAll();
qDebug() << "Err: " << resp->error();
qDebug() << "Err String: " << resp->errorString();
qDebug() << "Status code " << resp->attribute(QNetworkRequest::HttpStatusCodeAttribute);
}