从qwebkit读取下载的数据
来源:互联网 发布:数据库第六版pdf 编辑:程序博客网 时间:2024/06/07 06:20
主要有如下几个要点
1.从qwebview中获取qnetworkaccessmanager,然后重写createRequest
QNetworkReply *myNetworkAccessManager::createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData){ QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData); //连接到reply的readyRead信号 return reply;}
2.在reply接收的槽函数中,读取每次读的数据,特别需要注意的是读数据的时候千万不要使用readAll(),因为调用了readAll之后,Qt会自动清除资源,(导致无法继续了),所以一定要调用QIODevice的peek接口,来查看数据。
参考文章:http://stackoverflow.com/questions/11132747/qt-reading-data-from-qwebviews-qnetworkaccessmanager/11476348#11476348
I tinkered around with Qt (which I'm new to) and found a way to catch all resources downloaded by WebKit. Here's how:
1) Create your own subclass of QNetworkAccessManager
2) In your derived class, override virtual function createRequest
3) Call base class implementation to get the response object. After that you can look at the URL (or other parameters) and determine whether you need to capture that particular resource or not
4) if you do - connect readyRead signal to some slot that will capture the data
5) in that slot call peek function to read data so that WebKit will get the data also
6) After creating QWebPage object, call setNetworkAccessManager and pass a newly created instance of your subclass from step 1)
- 从qwebkit读取下载的数据
- qwebkit的套壳开发
- 从网站上读取数据的方法
- 从网站上读取数据的方法
- 从seq_file接口读取的数据不全
- 改进版的从文本文件读取数据
- java从控制台读取数据的方式
- java 从控制台读取数据,文件的读取与写入
- 从命令行读取数据
- 从控制台读取数据
- 从SocketChannel读取数据
- 从SocketChannel读取数据
- 从网络读取数据
- 从文件读取数据
- 读取数据从Uri
- 从JMSBytesMessage读取数据
- QWebKit对Html文件的解析
- MIT-BIH心电数据的下载和读取
- Google Test(GTest)使用方法和源码解析——模板类测试技术分析和应用
- monkey约束类命令
- 自定义View实现SwichButton效果
- 到v
- 《JavaScript高级程序设计》——JS中其他对象与常用方法
- 从qwebkit读取下载的数据
- go源码阅读笔记(math.4)
- Block 为什么要用copy属性
- SQL语句order by两个字段同时排序。
- LeetCode之8_String to Integer (atoi)
- uml 规范
- monkey调试类命令
- Android之EditText
- Android --- Recyclerview and Cardview