qnetworkaccessmanager

qt networkManager get

◇◆丶佛笑我妖孽 提交于 2019-12-13 12:46:00
问题 I want to download the url entered in the line edit widget. I am not able to get it working , can some one please give me a short code snippet which can put the values of the file to a QString ? void imdb::on_imdbGetButton_clicked() { Qstring link1 = ui->lineEdit2->text(); // QString link1 is the url to be downloaded. } I have added , the required header files.. Thanks.. 回答1: I guess you're trying to download a file via http . Here's what you could do: In you *.pro file add QT += network

On MacOSX, QNetworkAccessManager gets into an infinite loop when invalid auth credentials specified

早过忘川 提交于 2019-12-12 16:28:40
问题 In my cross-platform app, I use QNetworkAccessManager to send HTTP requests to my HTTP service that requires authentication. I recently upgraded to QT5, and to my complete surprise on MacOSX my app would send a massive amount of requests to the my service as fast as possible in some scenarios. After doing some debugging, it turns out that this would only happen when I specify bad auth credentials in my requests. QNetworkAccessManager would indefinitely resend requests to my service if invalid

QNetworkAccessManager: post http multipart from serial QIODevice

懵懂的女人 提交于 2019-12-12 10:43:27
问题 I'm trying to use QNetworkAccessManager to upload http multiparts to a dedicated server. The multipart consists of a JSON part describing the data being uploaded. The data is read from a serial QIODevice, which encrypts the data. This is the code that creates the multipart request: QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); QHttpPart metaPart; metaPart.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); metaPart.setHeader(QNetworkRequest:

Qt Console app using QNetworkAccessManager

大憨熊 提交于 2019-12-12 04:43:31
问题 I'm trying to write a Qt app that calls a web service. This is a console app, and url will be passed in as a command line argument. I searched for example http programs in Qt and found this link: http://qt-project.org/doc/qt-5/qnetworkaccessmanager.html Here it has the following code example: QNetworkAccessManager *manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); manager->get(QNetworkRequest(QUrl("http:/

QNetworkReply causes segfault

时间秒杀一切 提交于 2019-12-12 04:32:57
问题 I'm trying to write some kind of API client for PyQt4-based app. And, following this documentation i wrote this code: from PyQt4 import QtCore, QtNetwork class API(QtCore.QObject): def processResponse(self, response): print 'response' response.deleteLater() def processError(self, error): print 'error' def authenticate(self, authUrl, login, password): manager = QtNetwork.QNetworkAccessManager() request = QtNetwork.QNetworkRequest(QtCore.QUrl(authUrl)) reply = manager.get(request) reply.error

Cannot retrieve page contents through HTTPS with QNetworkAccessManager

﹥>﹥吖頭↗ 提交于 2019-12-11 16:14:50
问题 I am trying to connect to a HTTPS website (for example, Netflix), but cannot retrieve content of the page. I got OpenSSL lib in my folder and .pro, but I don't know what's wrong. Thanks for your time. Screenshot of the error: Screenshot of the .pro: As you can see, the console is empty. The code: void get_page(){ QEventLoop eventLoop; QNetworkAccessManager mgr; QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit())); QSslConfiguration sslConfig = QSslConfiguration:

What is the correct way to “stop / shutdown” a QNetworkAccessManager?

独自空忆成欢 提交于 2019-12-11 14:15:10
问题 I have a QNetworkAccessManager . Let's assume I have a pending request: QNetworkRequest request(url); this->m_networkManager->get(request) Can I shutdown the QNetworkAccessManager at any time? I am asking because I see a write access violation when I destruct my object m_networkManager during a pending get request. Or how can I safely destroy the manager, there seems to be no stop or shutdown functionality. 回答1: The root cause is that our QNetworkAccessManager is used in a threaded worker (1)

Qt QNetworkAccessManager long delay to emit finished signal

醉酒当歌 提交于 2019-12-11 10:35:51
问题 I use a QNAM to handle uploads using a ftp protocol. The whole process works but I have a strange behavior: this is my method : void ftp::uploadFile(const QString &origin, const QString &destination) { QUrl url("ftp://"+host+""+destination); url.setUserName(user); url.setPassword(pwd); url.setPort(21); localFile = new QFile(origin, this); if (localFile->open(QIODevice::ReadOnly)) { reply = nam->put(QNetworkRequest(url), localFile); QObject::connect(reply, SIGNAL(uploadProgress(qint64, qint64)

TypeError: native Qt signal is not callable

醉酒当歌 提交于 2019-12-11 09:32:13
问题 I'm trying to make a request to a protected webpage, so therefore I'm trying to authenticate with help from QAuthenticator() . However, I get the following error: mgr.authenticationRequired(response, auth) TypeError: native Qt signal is not callable This is a part of my script: def authenticate(self): username = 'user' password = 'pass' url = 'http://someurl.com' mgr = QNetworkAccessManager(self) auth = QAuthenticator() auth.setUser(username) auth.setPassword(password) response =

QNetworkReply - connection established, first byte written, etc

别说谁变了你拦得住时间么 提交于 2019-12-11 04:46:55
问题 I'd like to log the lifetime of a QNetworkReply object. This includes: When the underlying socket connection is established When the first byte of the request is sent When the first byte of the response received When the last byte of the response finished (3) and (4) can be determined by listening for the downloadProgress signal, but I'm not sure how to do (1) and (2). Is there a way to listen on the underlying socket of a QNetworkReply? The uploadprogress signal doesn't seem to be triggered