星小夜的登录器  v1.0
Public 槽 | 信号 | Public 成员函数 | Public 属性 | Private 属性 | 所有成员列表
Pettip类 参考

精灵技能快查窗口类 这个类写了整整一天,格式化精灵技能真难 更多...

#include <pettip.h>

类 Pettip 继承关系图:
Inheritance graph
[图例]
Pettip 的协作图:
Collaboration graph
[图例]

Public 槽

void slot_tip ()
 展示查询内容(ie控件模式) 更多...
 
void slot_replayFinished (QNetworkReply *reply)
 读取精灵技能 更多...
 
void slot_getname (QString name)
 读取json中精灵名称对应的图鉴地址 更多...
 
void slot_buttonget ()
 精灵技能查询 更多...
 

信号

void sendmes (QString msg)
 

Public 成员函数

 Pettip (QWidget *parent=0)
 精灵技能快查窗口构造函数 更多...
 
 ~Pettip ()
 精灵技能快查窗口析构函数 更多...
 

Public 属性

QString petname
 
QJsonObject jsonObject
 
QJsonParseError parseJsonErr
 
QNetworkAccessManager * m_manager
 

Private 属性

Ui::Pettip * ui
 

详细描述

精灵技能快查窗口类 这个类写了整整一天,格式化精灵技能真难

在文件 pettip.h36 行定义.

构造及析构函数说明

◆ Pettip()

Pettip::Pettip ( QWidget *  parent = 0)
explicit

精灵技能快查窗口构造函数

参数
parent父类指针
返回

在文件 pettip.cpp19 行定义.

19  :
20  QWidget(parent),
21  ui(new Ui::Pettip)
22 {
23  ui->setupUi(this);
24  setAttribute(Qt::WA_QuitOnClose,false);
25  //ui->axWidget->setControl(QString::fromUtf8("{8856F961-340A-11D0-A96B-00C04FD705A2}"));//注册组件ID
26  //ui->axWidget->setProperty("DisplayAlerts",false);//不显示警告信息
27  //ui->axWidget->setProperty("DisplayScrollBars",true);//不显示滚动条
28  m_manager = new QNetworkAccessManager(this);//新建QNetworkAccessManager对象
29  connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(slot_replayFinished(QNetworkReply*))); //关联信号和槽
30  connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(slot_buttonget()));
31 
32  QFile file(allpath+"/json/data.json");
33  file.open(QIODevice::ReadOnly | QIODevice::Text);
34  QString value = file.readAll();
35  file.close();
36 
37  QJsonDocument document = QJsonDocument::fromJson(value.toUtf8(), &parseJsonErr);
38  jsonObject = document.object();
39 
40 
41 
42 
43 }
函数调用图:

◆ ~Pettip()

Pettip::~Pettip ( )

精灵技能快查窗口析构函数

返回

在文件 pettip.cpp85 行定义.

86 {
87  delete ui;
88  delete m_manager;
89 }

成员函数说明

◆ sendmes

void Pettip::sendmes ( QString  msg)
signal
这是这个函数的调用关系图:

◆ slot_buttonget

void Pettip::slot_buttonget ( )
slot

精灵技能查询

返回

在文件 pettip.cpp48 行定义.

48  {
49  petname=ui->textEdit->toPlainText();
50  qDebug()<<jsonObject[petname];
51  if(jsonObject[petname].isNull())
52  emit sendmes("当前精灵不存在,请输入完整名字");
53  else{
54  if (!(parseJsonErr.error == QJsonParseError::NoError)) {
55  qDebug()<<"配置文件错误!";
56  return;
57  }
58  emit sendmes(petname+"的技能查询中");
59  m_manager->get(QNetworkRequest(QUrl(jsonObject[petname].toString())));//发送请求
60  }
61 }
这是这个函数的调用关系图:

◆ slot_getname

void Pettip::slot_getname ( QString  name)
slot

读取json中精灵名称对应的图鉴地址

参数
name精灵名称
返回

在文件 pettip.cpp67 行定义.

67  {
68 
69  petname=name;
70  qDebug()<<jsonObject[petname];
71  if(jsonObject[petname].isNull())
72  emit sendmes("当前精灵不存在,请输入完整名字");
73  else{
74  if (!(parseJsonErr.error == QJsonParseError::NoError)) {
75  qDebug()<<"配置文件错误!";
76  return;
77  }
78  m_manager->get(QNetworkRequest(QUrl(jsonObject[petname].toString())));//发送请求
79  }
80 }

◆ slot_replayFinished

void Pettip::slot_replayFinished ( QNetworkReply *  reply)
slot

读取精灵技能

参数
reply网页返回内容
返回

在文件 pettip.cpp108 行定义.

109 {
110  QTextCodec *codec = QTextCodec::codecForName("GBK");
111  //使用utf8编码, 这样可以显示中文
112  QString str = codec->toUnicode(reply->readAll());
113  //qDebug()<<str;
114  str.replace(QString("\n"), QString(""));
115  str.replace(QString("\t"), QString(""));
116  str.replace(QString("\r"), QString(""));
117 
118  QString tmp;
119  QStringList li=str.split("<tbody>");
120  QStringList li1;
121  for(int i=0;i<li.length();i++){
122  li1=li[i].split("</tbody>");
123  if(li1.length()!=0)
124  tmp=li1[0];
125  }
126  //tmp.replace("<td>","");
127  //tmp.replace("</td>","");
128  ui->tableWidget->clear();
129  ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);//
130  ui->tableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
131  li=tmp.split("</tr>");
132  QStringList header;
133  header << QStringLiteral("技能名") << QStringLiteral("攻击类型") << QStringLiteral("威力")<<QStringLiteral("PP")<<QStringLiteral("学习等级")<<"技能效果";
134  ui->tableWidget->setRowCount(li.length());
135  ui->tableWidget->setColumnCount(6);
136  ui->tableWidget->setHorizontalHeaderLabels(header);
137  ui->tableWidget->horizontalHeader()->setSectionResizeMode(0,QHeaderView::ResizeToContents);
138  ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
139  ui->tableWidget->horizontalHeader()->setSectionResizeMode(2,QHeaderView::ResizeToContents);
140  ui->tableWidget->horizontalHeader()->setSectionResizeMode(3,QHeaderView::ResizeToContents);
141  ui->tableWidget->horizontalHeader()->setSectionResizeMode(4,QHeaderView::ResizeToContents);
142  ui->tableWidget->horizontalHeader()->setSectionResizeMode(5,QHeaderView::ResizeToContents);
143  for(int i=0;i<li.length();i++){
144  li1=li[i].split("</td>");
145  for(int j=0;j<li1.length();j++){
146  li1[j].replace("<td>","");
147  li1[j].replace("<td style=\"text-align:left\">","");
148  li1[j].replace("<tr>","");
149  li1[j].replace("<tr class=\"odd\">","");
150  if(li1[j].indexOf("check")!=-1 || li1[j].indexOf("rel")!=-1)
151  break;
152  ui->tableWidget->setItem(i, j, new QTableWidgetItem(li1[j]));
153  qDebug()<<li1[j];
154  }
155  }
156  //qDebug()<<str.indexOf("<tbody>");
157  //qDebug()<<str.indexOf("</tbody>");
158  //qDebug()<<str.mid(str.indexOf("<tbody>"),str.indexOf("</tbody>"));
159  //qDebug()<<str;
160  //QRegExp rx("<tbody.*?>*</tbody>");
161  //QRegExp rx("[a-zA-z]+://[^\\s]*");
162  //int pos = rx.indexIn(str);
163  //qDebug() << pos;
164  //for(int i=0;i<pos;i++)
165  // qDebug()<<rx.cap(i);
166  reply->deleteLater();//最后要释放replay对象
167 }
这是这个函数的调用关系图:

◆ slot_tip

void Pettip::slot_tip ( )
slot

展示查询内容(ie控件模式)

返回
无 已作废,换用table来展示

在文件 pettip.cpp95 行定义.

95  {
96  //ui->axWidget->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}"));
97  //ui->axWidget->setControl(QString::fromUtf8("{8856F961-340A-11D0-A96B-00C04FD705A2}"));//注册组件ID
98  //QString str=QString("http://news.4399.com/seer/tujian/64106.htm");//设置要打开的网页
99  //ui->axWidget->dynamicCall("Navigate(QString)",str);//显示网页
100 
101 
102 }

类成员变量说明

◆ jsonObject

QJsonObject Pettip::jsonObject

在文件 pettip.h44 行定义.

◆ m_manager

QNetworkAccessManager* Pettip::m_manager

在文件 pettip.h47 行定义.

◆ parseJsonErr

QJsonParseError Pettip::parseJsonErr

在文件 pettip.h45 行定义.

◆ petname

QString Pettip::petname

在文件 pettip.h43 行定义.

◆ ui

Ui::Pettip* Pettip::ui
private

在文件 pettip.h56 行定义.


该类的文档由以下文件生成:
Pettip::slot_replayFinished
void slot_replayFinished(QNetworkReply *reply)
读取精灵技能
Definition: pettip.cpp:108
Pettip::ui
Ui::Pettip * ui
Definition: pettip.h:56
Pettip::sendmes
void sendmes(QString msg)
Pettip::jsonObject
QJsonObject jsonObject
Definition: pettip.h:44
Pettip::petname
QString petname
Definition: pettip.h:43
Pettip::parseJsonErr
QJsonParseError parseJsonErr
Definition: pettip.h:45
allpath
QString allpath
登录器运行目录
Definition: ext.cpp:45
Pettip::m_manager
QNetworkAccessManager * m_manager
Definition: pettip.h:47
Pettip::slot_buttonget
void slot_buttonget()
精灵技能查询
Definition: pettip.cpp:48