qnetworkaccessmanager

Sending an HTTP request using QNetworkAccessManager

﹥>﹥吖頭↗ 提交于 2019-11-28 12:26:10
问题 I've got a problem trying to send a request using QNetworkAccessManager from a QObject derived class. Firstly in my constructor I do the following: QObject::connect( &mAccessManager, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( requestFinished( QNetworkReply* ) ) ); Then when I wish to send the request I do the following: QNetworkRequest checkLogin( QUrl( address ) ); checkLogin.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); mByteArray = QByteArray(

Qt Download File - QNetworkAccessManager, not getting data

与世无争的帅哥 提交于 2019-11-28 09:50:49
问题 I'm trying to have my application download a file from a URL, typically an EXE or a Jar, not that this should change much though. I have this all running in a thread, but I don't think that will make a difference (if it does let me know). So Do_Download is my function that creates the manager, sets the URL and request, and performs get. I then try to connect the finished signal to the slot the will write the file. void DownloadManager::Do_Download() { QNetworkAccessManager *netManager = new

Qt signal slot connection - QNetworkAccessManager

徘徊边缘 提交于 2019-11-28 08:56:19
问题 Im new in Qt and im trying to understand the following signal-slot connection: m_networkManager = new QNetworkAccessManager(this); QNetworkReply *reply = m_networkManager->get(request); connect(reply, SIGNAL(finished()),this, SLOT(onRequestCompleted())); Why we connect the "finished" signal after the get-request?...What happened, if the network connection in line-2 was faster executed before the slot connection (line-3) was made? I know, that this code will work. but i want to understand how

Basic authentication with Qt (QNetworkAccessManager)

╄→гoц情女王★ 提交于 2019-11-27 21:19:27
问题 I was trying to perform basic authentication for Twitter from my Qt app. I use QNetworkAccessManager. But I couldn't find any help on this. But I found a program called qsoapmanager which passes credentials in base64 through the header. Maybe I can do this with QNAM by setting header in QNetowrkRequest. But I failed to find a way. In qsoapman source, header is set like this: QHttpRequestHeader header; header.setValue( "Authorization", QString( "Basic " ).append( auth.data() ) ); Can I do just

How to tell QWebPage not to load specific type of resources?

五迷三道 提交于 2019-11-27 11:03:38
How to tell QWebPage not to load specific type of resources like js, css or png? The solution is to extend QNetworkAccessManager class and override it's virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it's the one we don't want to download we create and hand over an empty request instead of the real one. Below is a complete, working example. #include <QApplication> #include <QUrl> #include <QtWebKit/QWebPage> #include <QtWebKit/QWebFrame> #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkRequest>

How to tell QWebPage not to load specific type of resources?

随声附和 提交于 2019-11-26 15:26:34
问题 How to tell QWebPage not to load specific type of resources like js, css or png? 回答1: The solution is to extend QNetworkAccessManager class and override it's virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it's the one we don't want to download we create and hand over an empty request instead of the real one. Below is a complete, working example. #include <QApplication> #include <QUrl> #include <QtWebKit/QWebPage>