-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.h
50 lines (39 loc) · 1.42 KB
/
link.h
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
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef LINK_H
#define LINK_H
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QString>
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
class Link : public QObject {
Q_OBJECT
public:
explicit Link( QString Url = "", QString parameter = "" );
~Link();
void setUrl( QString Url );
void
setParameter( QString formalParam,
QString actualParam ); //设置参数(前面是形参,后面是实参)
QString getUrl() const;
QString getParameter() const;
void
addParameter( QString formalParam,
QString actualParam ); //添加参数(前面是形参,后面是实参)
void connect( const QObject *receiver,
const char *member ) const; //绑定槽函数(网络请求完成时触发槽函数)
void disconnect() const; //解除connect绑定
void disconnect( const QObject *receiver,
const char *member ) const; //解除connect绑定
void post() const; //利用POST方式发送请求
bool checkNetwork() const;
static QByteArray getReply(
QNetworkReply
* ); //获取回应信息(QByteArray),这是static函数,可以不创建对象直接用
static QJsonObject jsonDecode(const QByteArray &); //解析Json对象,并返回一个QJsonObject对象
private:
QString Url; //网络ip地址
QString parameter; //发送的参数
QNetworkAccessManager *manage;
};
#endif // LINK_H